Results 1 to 9 of 9
- 06-15-2011, 05:08 AM #1
Senior Member
- Join Date
- Nov 2010
- Posts
- 150
- Rep Power
- 3
I am getting a cannot find symbol error on this code from Oracle Java tutorial site
After I compile this, I get an error saying that day cannot find symbol but this is the code provided by the Java site.
Do you get the same error and do you know if I should worry about it or is there a way to circumvent it?Java Code:public class EnumTest { Day day; public EnumTest(Day day) { this.day = day; } public void tellItLikeItIs() { switch (day) { case MONDAY: System.out.println("Mondays are bad."); break; case FRIDAY: System.out.println("Fridays are better."); break; case SATURDAY: case SUNDAY: System.out.println("Weekends are best."); break; default: System.out.println("Midweek days are so-so."); break; } } public static void main(String[] args) { EnumTest firstDay = new EnumTest(Day.MONDAY); firstDay.tellItLikeItIs(); EnumTest thirdDay = new EnumTest(Day.WEDNESDAY); thirdDay.tellItLikeItIs(); EnumTest fifthDay = new EnumTest(Day.FRIDAY); fifthDay.tellItLikeItIs(); EnumTest sixthDay = new EnumTest(Day.SATURDAY); sixthDay.tellItLikeItIs(); EnumTest seventhDay = new EnumTest(Day.SUNDAY); seventhDay.tellItLikeItIs(); } }
- 06-15-2011, 05:11 AM #2
- 06-15-2011, 05:13 AM #3
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
It looks like you are missing the underlying day enum.
- 06-15-2011, 05:17 AM #4
Well spotted sunde. From the tutorial:
Java Code:public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }
- 06-15-2011, 05:17 AM #5
Senior Member
- Join Date
- Nov 2010
- Posts
- 150
- Rep Power
- 3
Java Code:----jGRASP exec: javac -g EnumTest.java EnumTest.java:2: cannot find symbol symbol : class Day location: class EnumTest Day day; ^ EnumTest.java:4: cannot find symbol symbol : class Day location: class EnumTest public EnumTest(Day day) { ^ EnumTest.java:10: cannot find symbol symbol : variable MONDAY location: class EnumTest case MONDAY: System.out.println("Mondays are bad."); ^ EnumTest.java:13: cannot find symbol symbol : variable FRIDAY location: class EnumTest case FRIDAY: System.out.println("Fridays are better."); ^ EnumTest.java:16: cannot find symbol symbol : variable SATURDAY location: class EnumTest case SATURDAY: ^ EnumTest.java:17: cannot find symbol symbol : variable SUNDAY location: class EnumTest case SUNDAY: System.out.println("Weekends are best."); ^ EnumTest.java:26: cannot find symbol symbol : variable Day location: class EnumTest EnumTest firstDay = new EnumTest(Day.MONDAY); ^ EnumTest.java:28: cannot find symbol symbol : variable Day location: class EnumTest EnumTest thirdDay = new EnumTest(Day.WEDNESDAY); ^ EnumTest.java:30: cannot find symbol symbol : variable Day location: class EnumTest EnumTest fifthDay = new EnumTest(Day.FRIDAY); ^ EnumTest.java:32: cannot find symbol symbol : variable Day location: class EnumTest EnumTest sixthDay = new EnumTest(Day.SATURDAY); ^ EnumTest.java:34: cannot find symbol symbol : variable Day location: class EnumTest EnumTest seventhDay = new EnumTest(Day.SUNDAY); ^ 11 errors ----jGRASP wedge2: exit code for process is 1. ----jGRASP: operation complete.
- 06-15-2011, 05:19 AM #6
Senior Member
- Join Date
- Nov 2010
- Posts
- 150
- Rep Power
- 3
- 06-15-2011, 05:20 AM #7
Member
- Join Date
- Jun 2011
- Location
- San Diego, CA
- Posts
- 24
- Rep Power
- 0
EDIT: Disregard, I was too slow. You already saw the posts.
Sunde887 called it. You are missing the Day enum class. Junky posted the missing code just before your last post.Last edited by JDScoot; 06-15-2011 at 05:25 AM.
- 06-15-2011, 05:22 AM #8
Senior Member
- Join Date
- Nov 2010
- Posts
- 150
- Rep Power
- 3
Yes, thank you to you both Junky and JDScoot as well. I added the code. The way the example on the oracle site is, it is separated so I did not realize that it should go together.
Thanks!
- 06-15-2011, 05:26 AM #9
Similar Threads
-
this is the error i get: cannot find symbol method parseString(java.lang.String)
By Elcliff in forum New To JavaReplies: 10Last Post: 12-22-2010, 01:12 AM -
java:92: cannot find symbol error
By noviceNewbie in forum AWT / SwingReplies: 3Last Post: 12-18-2010, 02:46 AM -
New Java Video Tutorial Site thebestvideotutorials dot com
By thebestvideotutorials in forum New To JavaReplies: 0Last Post: 02-15-2009, 11:43 PM -
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM -
[SOLVED] Java Error: Cannot find Symbol...
By bobleny in forum New To JavaReplies: 8Last Post: 04-15-2008, 06:35 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks