aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What's the difference? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What Watch "What New topic
Author

What's the difference?

siva prasaad
Greenhorn

Joined: Jan 10, 2007
Posts: 23
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

Joined: Jan 10, 2007
Posts: 122
Only the second version will be compilable...
siva prasaad
Greenhorn

Joined: Jan 10, 2007
Posts: 23
reasoning please.
Atul Sawant
Ranch Hand

Joined: Jul 06, 2006
Posts: 304
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.


Mission SCWCD. Mission SCJP Complete: SCJP 1.4 - 91%
siva prasaad
Greenhorn

Joined: Jan 10, 2007
Posts: 23
Does the same applies for objects also??
Atul Sawant
Ranch Hand

Joined: Jul 06, 2006
Posts: 304
Yes.

Coding would really help you more. There are many things which we can just find out through coding.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What's the difference?