• Post Reply Bookmark Topic Watch Topic
  • New Topic

private class - resurrected  RSS feed

 
N Sam
Ranch Hand
Posts: 77
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was going through the a thread here that mentions "private classes are non-existant in java" and why it is so. (This is the thread). But, when i was reading the book "Effective Java by Joshua Bloch" there is a sentence on page 34 that starts with "the class is private or package-private....". How come this author is referring to a private class, while the above thread is discuss how private class is meaningless ? The only explanation that i can think of is that the author is referring to private class in a nested inner class (which seems legal). Just want to double check my understanding with experts.


 
Vijitha Kumara
Bartender
Posts: 4002
42
Chrome Fedora Hibernate
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
N Sam wrote: ... But, when i was reading the book "Effective Java by Joshua Bloch" there is a sentence on page 34 that starts with "the class is private or package-private....". How come this author is referring to a private class, while the above thread is discuss how private class is meaningless ? ...


Well you'd have to read the complete lesson that statement has been made and post what you understand. Not everyone here may have the book so might not be able to comment on without the entire context.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't read the whole thread, I quickly scanned it, but I don't see anybody saying that private classes do not exist.

A top-level class cannot be private, but a nested class (a class defined inside another class) can.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!