0

Method

i want to work in java with method but i cant who can help me ?

3rd Aug 2022, 10:26 AM
Safiullah Karimi
Safiullah Karimi - avatar
5 Answers
+ 1
you should add more details to your question, what are you trying to achieve and if you have some code attempt that would be awesome for us to see. Folks here are happy to help!
3rd Aug 2022, 11:13 AM
Apollo-Roboto
Apollo-Roboto - avatar
0
i want to know how can i write a code in java with method
3rd Aug 2022, 11:26 AM
Safiullah Karimi
Safiullah Karimi - avatar
0
you should have a read at the java course, there is a whole section on classes and objects
3rd Aug 2022, 11:49 AM
Apollo-Roboto
Apollo-Roboto - avatar
0
I am studying computer in the university and I have an exam on Sunday and I don't know how to work with methods in Java. Can you guide me or write some code for me?
3rd Aug 2022, 12:26 PM
Safiullah Karimi
Safiullah Karimi - avatar
0
class Cube { // this is a property private double size; // this is a constructor public Cube(double size) { this.size = size; } // this is a method public double getVolume() { return size*size*size; } } you would use it like this: Cube cube = new Cube(5); System.out.println("volume: " + cube.getVolume()); methods are function that uses your object's informations. all of this is mentioned in the java course. There is a lot to methods and I highly recomend you to read more on Object Oriented Programming
3rd Aug 2022, 12:38 PM
Apollo-Roboto
Apollo-Roboto - avatar