+ 3
why this is not working? (java)
public class Agenda{ public int number=9; public int getNumber(){ return number; } public void setNumber(int n){ this.number = n; } } public class Program { public static void main(String[] args) { Agenda ag = new Agenda(); ag.setNumber(82); System.out.println(ag.getNumber); } }
6 Respuestas
+ 5
You forgot parenthesis :
System.out.println(ag. getNumber());
+ 3
what do you get as an output?
+ 2
Your welcome :)
0
is getnumber a pre defined function ?
0
..\Playground\:9: error: cannot find symbol
System.out.println(ag.getNumber);
^
symbol: variable getNumber
location: variable ag of type Agenda
1 error
0
lol, thanks