• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What's the difference?

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Only the second version will be compilable...
 
siva prasaad
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
reasoning please.
 
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the same applies for objects also??
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes.

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