Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
private enum member within same file, is it possible?
Oskar Morganstern
Greenhorn
Posts: 1
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public class Bridge { public enum Suits { CLUBS(20), DIAMONDS(20), HEARTS(30), SPADES(30), NOTRUMP(40) { public int getBidValue(int bid) { return ((bid-1)*30)+40; } }; Suits(int points) { this.points = points; } private int points; public int getBidValue(int bid) { return points * bid; } } public static void main(String[] args) { System.out.println(Suits.SPADES.points); } }
How come I can access points?
something which I declared as private. I know that if I declared the enum in a separate file that it would not be visible. But why is it visible within the same file?
Christophe Verré
Sheriff
Posts: 14691
16
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
A rancher asked the same question yesterday
Here
.
[My Blog]
All roads lead to JavaRanch
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
K & B, Chapter 3, Quiz Question 7
question 7 of chapter 3
What is the output for this Class
Name of enum object in all lower-case
Info concerning the updates to the SCJP 6 exam
More...