Results 1 to 3 of 3
Thread: Very simple q
- 12-26-2009, 12:14 AM #1
Member
- Join Date
- Dec 2009
- Posts
- 55
- Rep Power
- 0
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?
- 12-26-2009, 01:53 AM #2
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.
- 12-26-2009, 10:06 AM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
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.
kind regards,
Jos
Similar Threads
-
Simple AI?
By Atriamax in forum New To JavaReplies: 4Last Post: 12-23-2009, 10:35 PM -
New simple application using a simple database
By webbusiness23 in forum New To JavaReplies: 9Last Post: 08-03-2009, 02:55 AM -
Simple Help....
By jpnym15 in forum New To JavaReplies: 1Last Post: 11-11-2008, 02:33 PM -
Help with a very simple method for a very simple beginner.
By cakeman in forum New To JavaReplies: 2Last Post: 05-04-2008, 05:27 PM -
simple GUI
By dim_ath in forum New To JavaReplies: 3Last Post: 01-07-2008, 03:00 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks