0

What can i do to have a output in my program?

Output ? https://code.sololearn.com/czuQ9wAUvl23/?ref=app

6th Apr 2020, 6:39 AM
Malick Diagne
Malick Diagne - avatar
2 Respuestas
+ 3
Use System.out print() and also you need to make getter and setter method. Do like this public class vehicule { private String color; vehicule (String newColor) { color = newColor ; } public String getColor() { return color; } } public class Program { public static void main(String[] args) { vehicule v = new vehicule ("Vert"); System.out.print(v.getColor()); } }
6th Apr 2020, 6:46 AM
A͢J
A͢J - avatar
+ 1
as your class attribut 'color' is private, you should first create a getter method for it (in the class body). public getColor(){ return this.color; } and then print vehicule.getColor() (in the main function) System.out.println(vehicule.getColor())
6th Apr 2020, 6:52 AM
John Robotane
John Robotane - avatar