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 4 of 4

Thread: Question about the first curly bracket after your public class

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

    Default Question about the first curly bracket after your public class

    Ok so I had a question from class and it was what does it mean and happen if you don't have the { after your public class. So what does this mean for the program if you left it out does the program just fail to associate all the code with your class title? Thanks and sorry if this is super basic.


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Question about the first curly bracket after your public class

    What happened when you tried to compile a class that had that bracket missing?
    Improving the world one idiot at a time!

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

    Default Re: Question about the first curly bracket after your public class

    We are using the command prompt so it just says error you are missing a { nothing that really explains anything for me.

  4. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Question about the first curly bracket after your public class

    The curly brackets are used to define the start and end of any block of code (class, method, if, loop). So any code that is inside the brackets belongs to that class, method, if, loop. Note I said ANY block of code.
    public void someMethod() {
        {
            System.out.println("This is perfectly legal");
        }
    }
    Improving the world one idiot at a time!

Similar Threads

  1. Class world is public?
    By Alexred906 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 16th, 2013, 01:54 PM
  2. Java, calling another public class from within the main class giving problems.
    By RandomGaisha in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 26th, 2012, 02:30 PM
  3. Replies: 3
    Last Post: June 17th, 2012, 06:22 PM
  4. What's difference between public class and abstract class?
    By Java95 in forum Java Theory & Questions
    Replies: 7
    Last Post: January 24th, 2012, 07:37 AM
  5. Public class help/error
    By Plural in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 11th, 2010, 05:22 PM