+ 1
Help me to find out error.
class Vehicle{ private int id; Vehicle (){ setId (35); } vehicle(int a){ setId(a); } public void setId(int a){ id=a; } public int getId(){ return id; } } public class hello{ public static void main(String []args){ Vehicle v1=new Vehicle(); Vehicle v2 = new Vehivle(5787); // v1.setId(66); System.out.println(v1.getId()); System.out.println(v2.getId()); } }
5 Answers
+ 2
Sonali Kala , look at the corrected code đ±
https://code.sololearn.com/cnBSiKnsImr2/?ref=app
+ 2
class Vahicle
{
private int id;
Vehicle()
{
setId(35);
}
Vehicle(int a)
{
setId(a);
}
public void setId(int a)
{
id=a;
}
public int getId()
{
return id;
}
}
public class Hello
{
public static void main(String[] args)
{
Vehicle v1=new Vehical();
Vehicle v2=new Vehical(5322);
v1.setId(66);
System.out.println(v1.getId());
System.out.println(v2.getId());
}
}
+ 1
Some important notes:
1. Include the code in any question by saving it in code playground and adding with + button. So helpers can readily run it.
2. Include the full error message (s) in the question.
3. Read the error message(s). You'll be grateful for how much they teach.
0
Thanks TheWhÂĄteCat đ§đŹ
0
Sure Emerson Prado . I will take care next time