Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[newbie] Cannot access StaticInnerClass

 
Jon Camilleri
Ranch Hand
Posts: 664
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm following a book example, and somehow the code doesn't seem to access a static method. I didn't really understand how the methods getMin() and getMax() are related to public static Pair minmax(double[] values) method. I don't think I would use such a complicated way of retrieving a maximum or a minimum although it can be useful for organizing a number of values into a single array.





Compilation error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method minmax(double[]) is undefined for the type ArrayAlg

at homnetwork.bkr.training.StaticInnerClassTest.main(StaticInnerClassTest.java:14)
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you change "ArrayAlg.minmax(d);" to "ArrayAlg.Pair.minmax(d);"?
 
Rob Spoor
Sheriff
Pie
Posts: 20552
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Legg wrote:What happens if you change "ArrayAlg.minmax(d);" to "ArrayAlg.Pair.minmax(d);"?

Right. Because the static method minmax is not defined in class ArrayAlg, but in class ArrayAlg.Pair.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic