Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inner class (Sortnames)

 
Peter Gragert
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got the following nitpick (names are changed to not give away...) ;-)
snip------- means: cut out, not important.


snip--------
>public static main( String[] args )
snip-------
>ThisClass com = new ThisClass()
If you need to instantiate an inner class from within a static method, it seems that the best approach is to make the inner c
lass static.
>{
> public String getSecond( Object o)
> {
snip-------
>}
snip-------


I do not understand the remark fully: I nowhere declared
class ... ThisClass. So why it is an inner class?
It is inner implicit?
Where to put static?
On other times the compiler complains that a method used
in main has to be declared static. But the program was compiled without error (or warning) and runs perfectly.
Because I do not understand fully, I put static at all possible places, but each got an error message safe if the declaration is taken out of main.
There I need static because then it is used in static main.
I got the feeling, that nitpicking should have suggested
Take this definition out of main!??? But why should a
local variable to main become a property of the class if
learning to use ArrayList is the purpose?
 
Marilyn de Queiroz
Sheriff
Posts: 9063
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, Peter. My mistake.
 
Peter Gragert
Ranch Hand
Posts: 424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No problem, Marilyn! So I will go on with the next assigment!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic