0
can I take of opject from the method
example car(speed){ Car car1 = new Car(speed); } car1.move();
6 Réponses
+ 1
Denise Roßberg That's called swing a part of java which can use to make desktop application. If he is asking in core Java then we can't create a button.
And also I think he is asking to create object from method which is not possible because we create object from class.
+ 3
No you can't create an object from method Because methods are operations which perform by object. Like hand is object of class Body and slap can be method. Here slap is an operation perform by object hand.
You can create object from class.
+ 1
🅰🅹 - ɪ'ᴍ ᴄʀɪᴍɪɴᴀʟʟʏ ɢᴏᴏᴅ!
Many beginners tend to express their questions or ideas inaccurately. Instead of simply saying, no, that's not possible, I try to show solutions that come closest to what they want.
0
I want to creat button that mack an opject and get some information about this object in another method
0
Book Games This is not html where you will make button. This is java program.
0
Yes. In general:
public MyClass{
//a method which returns an object of MyClass
public MyClass getObject(){
return new MyClass();
}
}
Or you can write a method in another class which returns an object.
If you want to create a button you can't do this on sololearn but with an IDE for your PC. Here is a code example:
https://www.javatpoint.com/java-jbutton
Read the part where JButton implements an ActionListener.
There is a method which defines what should happen when you click the button.