+ 1
There is some error here... Can someone please let me know what should i do..??
class Calc { int num1; int num2; int result; public void perform() { result= num1*num2; } } public class Program { public static void main(String[] args) { Calc obj=new Calc(); obj.num1=5; obj.num2=4; obj.perform(); System.out println(obj.result); } }
4 odpowiedzi
+ 1
You don't need getters and setters..... The problem is the missing dot at "System. out println"
+ 10
Yeah you forget dot after System.out so it giving errors .
+ 5
Well, there is in fact only a dot missing in "System.out.println", BUT (maybe you just started with your Java course, then this is only an advice what to look up additionally), please take a look at your usage of accessibility modifiers and getter methods...
+ 3