Here is the code:
class Time {
public static void printTime (int hour, int minute) {
System.out.print (hour) ;
System.out.print (":") ;
System.out.print (minute) ;
}
public static void main (String[] args) {
hour = 11 ;
minute = 30 ;
printTime () ;
}
}
Here is what terminal says when I try to compile it:
david-allenders-macbook-pro:~ davidallender$ Javac Time.java
Time.java:9: cannot find symbol
symbol : variable hour
location: class Time
hour = 11 ;
^
Time.java:10: cannot find symbol
symbol : variable minute
location: class Time
minute = 30 ;
^
Time.java:11: printTime(int,int) in Time cannot be applied to ()
printTime () ;
^
3 errors
david-allenders-macbook-pro:~ davidallender$
I'm in the process of learning so I don't really know what's going on. Right now I'm in the section in the book about parameters in/on/within/above/preposition (I'm not sure what the right preposition is) methods.
- What does a parameter do?
- Why is it useful?
- What did I do wrong in the above code?
- What did the error message mean?