+ 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); } }

4th Jul 2017, 11:21 AM
D0vAk1N
D0vAk1N - avatar
6 Respuestas
+ 5
You forgot parenthesis : System.out.println(ag. getNumber());
4th Jul 2017, 11:31 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 3
what do you get as an output?
4th Jul 2017, 11:23 AM
Jordan Chapman
Jordan Chapman - avatar
+ 2
Your welcome :)
4th Jul 2017, 11:32 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
0
is getnumber a pre defined function ?
4th Jul 2017, 11:24 AM
Anupam Sharma
Anupam Sharma - avatar
0
..\Playground\:9: error: cannot find symbol System.out.println(ag.getNumber); ^ symbol: variable getNumber location: variable ag of type Agenda 1 error
4th Jul 2017, 11:29 AM
D0vAk1N
D0vAk1N - avatar
0
lol, thanks
4th Jul 2017, 11:32 AM
D0vAk1N
D0vAk1N - avatar