Friday, July 30, 2010

Static: Frodo.java

Courtesy of SCJP Sun® Certified Programmer for Java™ 6 Study Guide Exam (310-065) (9780071591065)
Chapter 1, Question 9











When this code is compiled, it give the following error:

Frodo.java:4: non-static method countGold(int,int) cannot be referenced from a static context
        System.out.println(countGold(myGold,6));
                           ^
1 error


However, Short myGold is autoboxed correctly to int.

No comments:

Post a Comment