+ 1

I can not find the error in this program?Please help me to find the error?

public class Vehicle{ private String color; Vehicle(){ this.setcolor("Blue"); } Vehicle(String A){ this.setcolor(A); } public void setcolor (String A){ this.setcolor=A; } public String getcolor{ return.color; } } public class pro{ public static void main (String [] args){ Vehicle v1=new Vehicle(); Vehicle v2=new Vehicle("Purple"); System.out.println(v2.getcolor()); } }

3rd Jan 2018, 3:19 PM
Akshaya
Akshaya  - avatar
1 Answer
+ 2
public void setcolor (String A){ this.color=A; //To assign value in A to the variable color } public String getcolor(){ return color; //no dot operator }
3rd Jan 2018, 3:42 PM
Jemima George