Badri Sarma

Ranch Hand
+ Follow
since Apr 01, 2003
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Badri Sarma


new Float("10.0F"); // there wont be any exception
new Float("10L"); // will raise a run time exception

Why this difference in F & L?

There are examples in JLS, please go through that.
And some could also confuse you..... :-)

I think that java creators are not clear about static variables, some time they talk about
1.Declare variable before use (OR)
2.You can assign variable before declaring (OR)
3.Method will return default value (like in the above case).

For only one situation there are so many exception, Is it not very confusing to learn Java itself.

I have been working in J2EE technologies from 6 yrs. Now i got a opportunity to work on C and Unix in my company.
And this work would be again on Websphere, Lotus all IBM products internals.

I am almost biased whether i need to go for that opportunity are not.
Because i feel that in future person should have knowledge/expertise in more than one technology.

Please let me know your opinion on this.
16 years ago
Vinod Thanks for replying to my queries.
But still doubt persist in my mind it is not 100% clear.
Can you brief me on "forward reference error".
Thanks Vinod for the reply. But still i have a doubt....

Originally posted by vinod balaji:

There wont be error in line 2, because since i is in static block(it means that declaration part is there somewhere).

Why the i = i + 1, cannot think in the same fashion as you mentioned "it means that declaration part is there somewhere" and compile the code.

Below is the prgram

class Test{
static int j = 100;
j = 200; // line 1
i = 500; // line 2
i = i + 1; // line 3
System.out.println(j+":value:"+i); // line 4
static int i = 200;

My assumption is error to be raised at line 2.
But error is raised at line 3.

Please let me know wky..

What would be the use case requirement for " I need to do Phone Call"

It might look simple, but i am not able to provide a standard Use Case Requirement specification solution.

Any inputs on the query?
And also let me know if there are any good tutorials on static variables & method declaration
What is the advantage of designing Custom Class Loader (Or)
Why Custom Class Loader to be designed?
16 years ago
Keith Lynn explanation was correct. when you use the following piece of code
String str[] = new String[10];

continious memory allocation would be created. No constructor will be called, at that point.
Yes. You can have private as access modifier for the constructor. Please check what is singleton pattern.

Originally posted by Sanjeev Kulkarni:
In the above case, you are calling peek() before 'j' is set to 1, that means, j = 0 when you call:

Sanjeev, if you look at the code the variable itself is declared after the method. So it should throw exception. So if method able to recognise j then it should be 1 not 0.

This was taken from JDK Specification

class Z {
static { i = j + 2; }
static int i, j;
static { j = 4; }

result in compile-time errors. Variable j was accessed before it is declared.

class Z {
static int peek() { return j; }
static int i = peek();
static int j = 1;
class Test {
public static void main(String[] args) {

produces the output:


Question is: how it is printing "0", when the static property needs to be declared before accessing?