Help me to find out error. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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()); } }

30th Dec 2021, 6:44 PM
Sonali Kala
Sonali Kala - avatar
5 Answers
30th Dec 2021, 7:14 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 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()); } }
1st Jan 2022, 10:49 AM
Muhammad Rizwan
Muhammad Rizwan - avatar
+ 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.
31st Dec 2021, 1:47 AM
Emerson Prado
Emerson Prado - avatar
30th Dec 2021, 7:23 PM
Sonali Kala
Sonali Kala - avatar
0
Sure Emerson Prado . I will take care next time
31st Dec 2021, 3:09 AM
Sonali Kala
Sonali Kala - avatar