
05-08-2008, 10:57 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,338
|
|
Ok, here is the solution.
In such a situation comes with compilation error. It's called forward reference. That mean when you referencing the variable j in variable i, compiler can't find variable j.
If you do it other way, like this
public class MyQuiz {
private int j = 10;
private int i = j;
public static void main(String args[])
{
System.out.println((new MyQuiz()).i);
}
}
prints 10 to the console.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|