Forums Register Login

What's the difference?

+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
Only the second version will be compilable...
+Pie Number of slices to send: Send
reasoning please.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Does the same applies for objects also??
+Pie Number of slices to send: Send
Yes.

Coding would really help you more. There are many things which we can just find out through coding.
World domination requires a hollowed out volcano with good submarine access. Tiny ads are optional.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 529 times.
Similar Threads
Getting error in this code??? why is that so?
A Question for beginners - 2
constructor
stange problem
About static method
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 19, 2024 04:53:59.