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
Ron McLeod
Paul Clapham
Devaka Cooray
Liutauras Vilda
Sheriffs:
Jeanne Boyarsky
paul wheaton
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Carey Brown
Mikalai Zaikin
Bartenders:
Lou Hamers
Piet Souris
Frits Walraven
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
I don't always make ads but when I do they're tiny
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
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...