Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What's the difference?

 
siva prasaad
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class demo1 {
int i;
i=0;
public static void main(String args [])
{
System.out.println("Demo Program Execution");
}

}
and
public class demo1 {
int i=0;
public static void main(String args [])
{
System.out.println("Demo Program Execution");
}

}

The only change i made:
1st prog:int i;
i=0;

2nd Prog:int i=0;

Which is correct...


(title edited to quieten it down to a question rather than a shout)
[ February 15, 2007: Message edited by: Barry Gaunt ]
 
Anton Uwe
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only the second version will be compilable...
 
siva prasaad
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
reasoning please.
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first version will not compile because in a class (not inside a method/block of code/inner class) accepts only declarations. Even System.out.prinln() is not accepted.
 
siva prasaad
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the same applies for objects also??
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.

Coding would really help you more. There are many things which we can just find out through coding.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic