jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes Hi to all Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hi to all" Watch "Hi to all" New topic
Author

Hi to all

zama syed
Greenhorn

Joined: Sep 28, 2010
Posts: 6
what is difference in s and s1 in the below program:


'm getting error for s1.........
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3575
    
  14

The difference is that s1 is a member of the class, whereas s is a local variable in the main method. The reason you're getting an error is that you can't have loose statements in the class body.
The line s1 = new String[10] should be either in a method or constructor body, or you should initialize s1 directly.
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1753
    
    7

Hi, and welcome to JavaRanch!
Please take a moment to read our FAQ on HowToAskQuestionsOnJavaRanch, specifically the secion on using meaningful subject lines.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Bobby Smallman
Ranch Hand

Joined: Sep 09, 2010
Posts: 107
What a tricky thread name! I got all excited that someone just wanted to say hi and THEN I feel very deceived when I find out there is a question in here! There must be some evil mastermind behind this dastardly thread!


Everyday in every way, we get a little better.
 
jQuery in Action, 2nd edition
 
subject: Hi to all
 
Similar Threads
Thread4
Confusion on the topic of String constant table ?
Boolean Question
String buffer
StringBuffer question