This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Statements in classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Statements in classes" Watch "Statements in classes" New topic
Author

Statements in classes

Raghuveer Mukkamalla
Greenhorn

Joined: Jan 30, 2005
Posts: 2
hi,

i've the following class and would like explaination of why the expression
x = 24 gives a compilation error. i assume its because its outside a method, but am looking for detailed explaination.

public class Example281 {

int x = 12;
x = 24;

public static void go( int x) {
System.out.println(x);
}

public static void main (String[] args) {
Example281 ex281 = new Example281();
ex281.go(25);
System.out.println(ex281.x);
}
}
Klaus Jesper
Greenhorn

Joined: Jan 20, 2005
Posts: 15
Hm, why should anyone first declare an integer value and than change it without accessing a method or anything else? Makes no sense I guess? Please tell me what you want to achieve.

Klaus
Paul Santa Maria
Ranch Hand

Joined: Feb 24, 2004
Posts: 236
Does this help?


Paul M. Santa Maria, SCJP
 
Have you checked out Aspose?
 
subject: Statements in classes
 
It's not a secret anymore!