just started oops in java ad getting an error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

just started oops in java ad getting an error

public class getterssetters { public static void main(String[] args) { pen p1 = new pen(); p1.setcolor("blue"); System.out.println(p1.getcolor()); } } class pen{ private String color; private int tip; String getcolor() { return this.color; } int gettip() { return this.tip; } void setcolor(String newcolor) { color = newcolor; } void settip(int tip) { this.tip = tip; } } error - Exception in thread "main" java.lang.NoSuchMethodError: 'void oops.pen.setcolor(java.lang.String)' at oops.getterssetters.main(getterssetters.java:8) output shuld be: blue

20th Dec 2022, 8:28 AM
RISHABH BHUTANI
RISHABH BHUTANI - avatar
3 Answers
+ 6
You can link your code like this: Go to Code section, click +, select the programming language, insert your **complete** code, save. Come back to the thread, click +, Insert Code, sort for My Code Bits, select your code.
20th Dec 2022, 11:10 AM
Lisa
Lisa - avatar
+ 2
RISHABH BHUTANI Recheck this code once.. It should work.
20th Dec 2022, 12:43 PM
Jayakrishna 🇮🇳
+ 2
Sorry, maybe it was a problem with my java debugger in vs code, i reinstalled that and my code is working now! I checked how to upload the link of the code. Thanks everyone
20th Dec 2022, 2:22 PM
RISHABH BHUTANI
RISHABH BHUTANI - avatar