Click to See Complete Forum and Search --> : Noob Java Question
RajaCode
July 21st, 2008, 05:24 AM
I noticed a semi-colan at the end a }
why would you need this? And why do you not have a ; at the end of all }
JFrame frame = new JFrame("FlowLayout Source Demo") {
public Dimension getMinimumSize() {
Dimension prefSize = getPreferredSize();
return new Dimension(100, prefSize.height);
} //why is there not a semi-colon here?
}; //why is there a semi-colon here?
dlorde
July 21st, 2008, 05:41 AM
In Java a semicolon ends a statement. Creating and assigning a new JFrame is a statement, the method declaration is not a statement.
This is basic Java syntax that you can pick up from any good reference, and there are plenty of specific explanations online if you know how to use a search engine, e.g. Expressions, Statements & Blocks (http://java.sun.com/docs/books/tutorial/java/nutsandbolts/expressions.html), and Those Pesky Semicolons (http://beginwithjava.blogspot.com/2008/06/those-pesky-semicolons.html).
This forum is not intended to teach Java, but to help people who get stuck. Please use some initiative and try to make a little effort to solve your problem before posting here.
They know enough who know how to learn...
J. Adams
koma_love
July 25th, 2008, 09:27 PM
JFrame frame = new JFrame("FlowLayout Source Demo") {
public Dimension getMinimumSize() {
Dimension prefSize = getPreferredSize();
return new Dimension(100, prefSize.height);
} //this is a method
}; //this is a statement,just as the following statement:
//JFrame frame=new JFrame("FlowLayout Source Demo");
codeguru.com
Copyright 2007 Jupitermedia Corporation All Rights Reserved.