Java Programming Tutorial - 63 - JButton Final Program
Top Comments
All Comments (170)
-
CLASSCEPTION!
-
@WhiteyMcCrackers Dont worry, image was the wrong size >.<
-
@WhiteyMcCrackers I've tried placing the images in the bin folder, but it still does not work...
What else could i try? The code is perfect :/
-
@WhiteyMcCrackers thx man
-
@MrYouMath Now you can create an instance of your class hero called Cloud
hero Cloud = new hero(100,20);
You can also create another hero. eg.Tifa
hero Tifa = new hero(80,30);
I hope you see what its good for:). The constructor just creates an instanc(new hero(). If you like it can create an instance with initialising variables (new hero(100,20);). Its very important that the constructor is public and its name has to be the name of the class.
-
@franchyze922 A constructor is something like a initialiser. if you create an instance of an object, then you mostly want to initialise your variables(members). E.g. you have a class called hero,with the variables hp and mp, for your game. And you want to create a hero instance called Cloud with hp = 100 and mp = 20. To not always assign these values you create a constructor e.g.:
public hero(int health, int magicpoints){ hp = health; mp = magicpoints;
}
-
can somebody please explain a constructor!??
-
a class inside a class?!?! CLASSCEPTION!!!
-
@mihek Bethesda would buy it too...
-
@mihek Do you have a mac then? :P
IF YOUR GETTING "Exception in thread "main" java.lang.NullPointerException at javax.swing.ImageIcon.init(Unknown Source) at Gui.init(Gui.java:31) at apples.main(apples.java:7)" ERROR Move Your Picture To Bin And Not Src!!!
THUMBS UP SO OTHER PEOPLE KNOW!
WhiteyMcCrackers 7 months ago 84
Microsoft would never buy this..... it does not contain any bugs, that's not their style...
mihek 4 months ago in playlist Java Programming Tutorials 28