When you makes this: NumWords myWord = nulll;
only declares the object myWord of type NumWords. not yet create a new instance. When you writes this: NumWords myWord = new NumWords(); Or NumWords myWord = null; //more code myWord = new myWord(); creates an new instance of NumWords class . 2010/12/8 Gagan Arora <gaganaror...@gmail.com> > Hello Ning, > > 1 and 2 is the syntax for Constructor declaration. Whenever you require an > object of NumWords you will write something like this > > NumWords myWord = new NumWords(); *This highlighted code refers the > constructor and sets the initial values for object myWord according to what > you will have in 2.* > > 3 is syntax for declaration of main method. Just to give you an idea the > application starts from main method. Consider it as entry point. > > Happy Coding > G > > On Wed, Dec 8, 2010 at 6:34 AM, Ning Yun (运宁) <officesucc...@gmail.com>wrote: > >> Hello my teacher and classmates, >> >> I'm studying InputFromKeyboard lesson from Javapassion. I found when >> we use swing classes, we sometimes add a statement "Public classname() >> {}"(as first two example), while we don't do that sometimes(as the >> last example). What is this statement used for? What's the difference >> between using it and not using it? >> >> -------------------------- >> 1."public class InputFromKeyboardJOptionPane { >> >> /** Creates a new instance of InputFromKeyboardJOptionPane */ >> public InputFromKeyboardJOptionPane() { >> }" >> -------------------------- >> 2. "import javax.swing.JOptionPane; >> >> public class NumWords { >> >> /** Creates a new instance of NumWords */ >> public NumWords() { >> }" >> ---------------------------- >> 3. "import javax.swing.JOptionPane; >> >> public class Grades { >> >> public static void main(String[] args) { " >> -------------------------------- >> >> Thank you very much in advance. >> >> Best regards, >> Ning >> >> -- >> To post to this group, send email to >> javaprogrammingwithpassion@googlegroups.com >> To unsubscribe from this group, send email to >> javaprogrammingwithpassion+unsubscr...@googlegroups.com<javaprogrammingwithpassion%2bunsubscr...@googlegroups.com> >> For more options, visit this group at >> http://groups.google.com/group/javaprogrammingwithpassion?hl=en > > > -- > To post to this group, send email to > javaprogrammingwithpassion@googlegroups.com > To unsubscribe from this group, send email to > javaprogrammingwithpassion+unsubscr...@googlegroups.com<javaprogrammingwithpassion%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/javaprogrammingwithpassion?hl=en > -- To post to this group, send email to javaprogrammingwithpassion@googlegroups.com To unsubscribe from this group, send email to javaprogrammingwithpassion+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en