Very simple q
Can someone explain this to me
//create the button
JButton button = new JButton("Button");
ok am i right that JButton is like what tells it what it is like a keyword,
button is the name of the button
but, after that i forget what the other 2 names are for and what there purposes are .
this is a constructor right?
JButton is an A class or data type, that is bundled in the Java standard API.
button is the name of an instance variable, or an identifier in technical terms I guess.
Equals is the assignment operator of course.
Yes, new JButton("Button") this is a constructor, in this case takes one argument of type String, that according to the API documentation will be used by the constructor in the object to set the name that this object will display.
To be exact: that is the 'new' operator; that operator always calls a constructor from a class. The 'new' operator allocates the raw memory for the object, initializes it to all bits zero and calls the constructors. Finally it returns the newly created object.
Originally Posted by fresh83