Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: How to fix ';' expected error : 47

  1. #1
    Junior Member
    Join Date
    Mar 2021
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation How to fix ';' expected error : 47

    public class Day {
     
     
        private static int day;
        private int days;
     
        public Day(int day) {
            Day.day = day;
        }
     
        public void main(String[] args) {
     
     
     
        }
     
             {
                        System.out.println(this.toString());
                    }
     
     
     
        private static final int SUNDAY = 0;
     
        private static final int MONDAY = 1 ;
     
        private static final int TUESDAY = 2;
     
        private static final int WEDNESDAY = 3;
     
        private static final int THURSDAY = 4;
     
        private static final int FRIDAY = 5;
     
        private static final int SATURDAY = 6;
     
        static {
            return switch (day) {
                case SUNDAY -> "Sun";
                case MONDAY -> "Mon";
                case TUESDAY -> "Tue";
                case WEDNESDAY -> "Wed";
                case THURSDAY -> "Thu";
                case FRIDAY -> "Fri";
                case SATURDAY -> "Sat";
                default -> "";
            } >>> LINE 47
        }
     
     
        static {
                        System.out.println("Test Program For The Day Class");
     
                        System.out.print("\nInitial day: ");
                        Day d = new Day(day);
                        d.print();
     
                        System.out.print("\nNext day: ");
                        d.setDay();
                        d.print();
     
                        System.out.print("\nNext day again: ");
                        d.setDay();
                        d.print();
     
                        System.out.println("\nUsing getDay() and toString() methods");
                        System.out.println("\tDay Index: " + d.getDay());
                        System.out.println("\tDay Name: " + d);
     
                        System.out.print("\nPrevious day: ");
                        d.setDay();
                        d.print();
     
                        System.out.print("\nNext week: ");
                        d.setDay();
                        d.print();
     
                        System.out.print("\nAdd 3 days: ");
                        d.setDay();
                        d.print();
     
                    }
     
     
        private boolean getDay() {
            return false;
        }
     
        private void setDay() {
        }
     
        private void print() {
        }
     
    }
    Last edited by phungwayo56@gmail.com; March 21st, 2021 at 02:16 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,071
    Thanks
    53
    Thanked 2,614 Times in 2,564 Posts

    Default Re: How to fix ';' expected error

    Please copy the full text of the error message and paste it here.
    It needs to show what line the error is on.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2021
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to fix ';' expected error : 47

    Error is on line 47

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,071
    Thanks
    53
    Thanked 2,614 Times in 2,564 Posts

    Default Re: How to fix ';' expected error : 47

    Line 47 is not marked in the posted code. Please add a comment on line 47: >>> LINE 47 so line 47 is easy to find.
    What is on that line?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Mar 2021
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How to fix ';' expected error : 47

    Done

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    24,071
    Thanks
    53
    Thanked 2,614 Times in 2,564 Posts

    Default Re: How to fix ';' expected error : 47

    A switch statement does not return anything. What is this statement supposed to do?
            return switch (day) {

    ';' expected error : 47
    What happens when you add a ; at the location where it is expected?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 2
    Last Post: March 23rd, 2014, 08:44 AM
  2. ; expected error
    By UM68 in forum Object Oriented Programming
    Replies: 13
    Last Post: September 18th, 2013, 04:23 PM
  3. error Identifier expected?
    By chandresh in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 15th, 2012, 02:34 AM
  4. '{' expected error please help
    By erdy_rezki in forum What's Wrong With My Code?
    Replies: 8
    Last Post: April 9th, 2012, 10:01 AM
  5. un-expected error
    By arvindbis in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 21st, 2011, 09:02 AM

Tags for this Thread