can I take of opject from the method | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

can I take of opject from the method

example car(speed){ Car car1 = new Car(speed); } car1.move();

3rd Dec 2019, 8:30 PM
Khaled Abd Al-hamead Hawwas
Khaled Abd Al-hamead Hawwas - avatar
6 Answers
+ 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.
4th Dec 2019, 8:03 AM
A͢J
A͢J - avatar
+ 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.
3rd Dec 2019, 9:12 PM
A͢J
A͢J - avatar
+ 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.
4th Dec 2019, 10:36 AM
Denise Roßberg
Denise Roßberg - avatar
0
I want to creat button that mack an opject and get some information about this object in another method
3rd Dec 2019, 9:38 PM
Khaled Abd Al-hamead Hawwas
Khaled Abd Al-hamead Hawwas - avatar
0
Book Games This is not html where you will make button. This is java program.
3rd Dec 2019, 10:14 PM
A͢J
A͢J - avatar
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.
3rd Dec 2019, 11:12 PM
Denise Roßberg
Denise Roßberg - avatar