JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
public class Car{
double speed = 6.5;
public double getSpeed(){
return speed;
}
public void setSpeed(double a){
this.speed = a;
}
public static void main(String []args){
//correct code
Car obj = new Car();
obj.setSpeed(15.7);
System.out.println(obj.getSpeed());
}
}
/*
Old code I was doing wrong like this.
Car obj = new Car();
obj.setSpeed(15.7);
System.out.println(obj);
*/
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run