Syntax error insert to complete classbody

I created a method and keep getting an error that I need to include a } at the end of my method. I put the } in and the error is still there! If I then delete that } the same error will pop up on a...

I created a method and keep getting an error that I need to include a } at the end of my method. I put the } in and the error is still there! If I then delete that } the same error will pop up on a prior method; and that error wasn’t there before. in other words, if i type the } on my most recent method then the error stays there and only there. if i delete it, it duplicates that error on my prior method.

private void putThreeBeepers() {
for (int i = 0; i < 2; i++) {
    putBeeper();
    move();
}
putBeeper();
}
private void backUp() {
turnAround();
move();
turnAround();
   }

TofuBeer's user avatar

TofuBeer

60.4k18 gold badges116 silver badges161 bronze badges

asked Oct 27, 2010 at 4:44

LuxuryMode's user avatar

LuxuryModeLuxuryMode

33.1k34 gold badges117 silver badges187 bronze badges

4

You really want to go to the top of your file and do proper and consistent indention all the way to the bottom.

For example…

private void putThreeBeepers() 
{
    for (int i = 0; i < 2; i++) {
        putBeeper();
        move();
    }

    putBeeper();
}

private void backUp() 
{
    turnAround();
    move();
    turnAround();
}

Odds are, somewhere along the line, you are missing a }. Your description isn’t super clear, but if the code you posted is how you actually have it formatted in your file then odds are you just missed something somewhere… and poor indentation makes it very hard to spot.

The fact that the message is changing is confusing, but it is the sort of thing you see in these cases.

answered Oct 27, 2010 at 4:51

TofuBeer's user avatar

6

the error might be misleading. In my case i had incorrect/incomplete comment statements such as below which is broken lead to this error:

/*
//  */
*/

Fixing the comments fixed the error. Hope this helps. Thanks.

Nick Rippe's user avatar

answered Oct 18, 2012 at 15:58

Jhenry's user avatar

JhenryJhenry

1412 silver badges3 bronze badges

1

I think this can be caused by a number of different problems. :(

In my case it was that I have forgotten to specify the type of two parameters in one of my methods declareations.
To fix I had to change this:
onUpgrade(SQLiteDatabase pDb, pOldVersion, pNewVersion)
{

}
to this:
onUpgrade(SQLiteDatabase pDb, int pOldVersion, int pNewVersion)

answered Dec 9, 2012 at 15:29

TomHanrath's user avatar

It might be due to invisible Chars when copying code from PDF ebook.
Be careful of the little red dot ‘.’

Choose ‘Select First Character’ -> then delete it.

Invisible Chars when copying code from PDF ebook

answered Mar 21, 2013 at 8:59

Cullen SUN's user avatar

Cullen SUNCullen SUN

3,5073 gold badges31 silver badges33 bronze badges

Also, the same error might occur if you accidentally write an if-statement outside of a method. I kept overlooking it since I was looking at the bracket-matching only.

answered Mar 22, 2013 at 2:37

jwBurnside's user avatar

jwBurnsidejwBurnside

7994 gold badges31 silver badges64 bronze badges

I just simply add another»}»,makes as «}}»,then problem solved

I didnt have to put anther «}» for my other java code exercise.

Im a java beginner,I’ve come across same problem so I searched online found this thread.Hope this help

answered Jan 12, 2014 at 3:30

Jane's user avatar

Had the same problem. Turned out to be a very fundamental oversight.
I was having the properties of a class declared like this:

private Texture foo;
private Sprite bar;
foo = new Texture();
bar = new Sprite();

The mistake was i had been instantiating the foo and bar variables outside the functions
of the class. When I put the

foo = new Texture();
bar = new Sprite();

into their proper functions (like below), the error went away.

private Texture foo;
private Sprite bar;
// function
public void instantiateVariables(){
foo = new Texture();
bar = new Sprite();
}

answered Jun 9, 2014 at 15:06

Balaji Sankar's user avatar

I got this error due to a missing <%.

answered Dec 23, 2016 at 16:23

Noumenon's user avatar

NoumenonNoumenon

4,4304 gold badges49 silver badges65 bronze badges

Here are the steps.

  1. Just copy paste your code in notepad
  2. Remove copy from Java file
  3. Again copy notepad and paste into Java file.
  4. An error will be gone.

Stephen Rauch's user avatar

Stephen Rauch

46.7k31 gold badges109 silver badges131 bronze badges

answered Sep 17, 2017 at 16:42

Dharmendra Pawar's user avatar

1

This question have already accepted answer but still there are some other problems where it occurs (like even though all statements are there correctly sometimes we will get this issue) and there are solutions too.

Recently I came across like this situation in eclipse workspace.

The solution is

  1. Take the back up of that java file.
  2. Remove the java file from that location and do the build/compile
  3. Paste the file in the same location and do the build/compile
  4. If the above step 3 does not work create new file and paste the content/code from backup file and do the build/compile
  5. If the above step 3&4 both are not working then type the code of that file manually end-to-end and do the build/compile

Dharman's user avatar

Dharman

29.3k21 gold badges80 silver badges131 bronze badges

answered Jan 8, 2021 at 16:41

Manohar Ch's user avatar

Manohar ChManohar Ch

4531 gold badge3 silver badges22 bronze badges

If this error comes in jsp, look for the braces. if open or close braces are missing, we will get this error.

answered Sep 23, 2021 at 9:51

Vinod's user avatar

VinodVinod

761 silver badge6 bronze badges

The problem, as many others have suggested here, is in the balancing of the braces, meaning each { opens a block of code and thus needs a matching } to close that block of code.
IDEs do make it easier to do this matching for you, many free text editors are available to do this matching for you.

So a few changes to your code:

This line }/* And here*/); delete /* And here*/ and replace it with }.

Next, the main class public class Password needs to be closed on the last line with a }.

Lastly, since the btnEnter2 needs to override the addActionListener abstract method, you have a typo in line public void actionPreformed(ActionEvent e) {, actionPreformed should be spelled actionPerformed to successfully override the addActionListener anonymous method.

The final code should resemble:

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JButton;

public class Password {

    private JFrame frame;
    private JTextField PassField;
    private JTextField txtSecretPasswords;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    Password window = new Password();
                    window.frame.setVisible(true);
                } 
                catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    /**
     * Create the application.
     */
    public Password() {
        initialize();
    }/* Here*/

    /**
     * Initialize the contents of the frame.
     */
    private void initialize() {
        frame = new JFrame();
        frame.setBounds(100, 100, 700, 650);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(null);

        PassField = new JTextField();
        PassField.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {


            }
        });
        PassField.setBounds(0, 42, 150, 32);
        frame.getContentPane().add(PassField);
        PassField.setColumns(10);

        txtSecretPasswords = new JTextField();
        txtSecretPasswords.setEditable(false);
        txtSecretPasswords.setText("Secret passwords");
        txtSecretPasswords.setBounds(0, 11, 131, 20);
        frame.getContentPane().add(txtSecretPasswords);
        txtSecretPasswords.setColumns(10);

        JButton btnEnter = new JButton("Enter");
        btnEnter.addActionListener(new ActionListener() {
            private JTextField txtMessage;
            private JTextField txtMessage2;
            private JTextField txtMessage3;
            private JTextField txtPass2;
            private JButton btnEnter2;
            public void actionPerformed(ActionEvent e) {
                int pass;
                pass = Integer.parseInt(PassField.getText());
                if (pass == 5441) {

                    txtMessage = new JTextField();
                    txtMessage.setEditable(false);
                    txtMessage.setText("Postal Code: 42658");
                    txtMessage.setBounds(0, 100, 130, 20);
                    frame.getContentPane().add(txtMessage);
                    txtMessage.setColumns(10);

                    txtMessage2 = new JTextField();
                    txtMessage2.setEditable(false);
                    txtMessage2 .setText("Email password: Vauxhal1");   
                    txtMessage2.setBounds(0, 125, 150, 20);
                    frame.getContentPane().add(txtMessage2);
                    txtMessage2.setColumns(10);

                    txtMessage3 = new JTextField();
                    txtMessage3.setEditable(false);
                    txtMessage3.setText("Steam password: Vauxhal12");   
                    txtMessage3.setBounds(0, 170, 200, 20);
                    frame.getContentPane().add(txtMessage3);
                    txtMessage3.setColumns(10);

                    btnEnter2 = new JButton();
                    btnEnter2.setText("Enter");
                    btnEnter2.setBounds(175, 250, 100, 15);
                    frame.getContentPane().add(btnEnter2);

                    btnEnter2.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {


                            int pass2;
                            pass2 = Integer.parseInt(txtPass2.getText());
                            if (pass2 == 030303) {
                                txtMessage3 = new JTextField();
                                txtMessage3.setEditable(false);
                                txtMessage3.setText("Steam password: Vauxhal12");   
                                txtMessage3.setBounds(0, 170, 200, 20);
                                frame.getContentPane().add(txtMessage3);
                                txtMessage3.setColumns(10); 


                        }
                            else {
                                JOptionPane.showMessageDialog(null, "Wrong");
                            }
                        }
                    });

                    txtPass2 = new JTextField();
                    txtPass2.setEditable(true);
                    txtPass2.setBounds(0, 250, 150, 20);
                    frame.getContentPane().add(txtPass2);
                    txtPass2.setColumns(10);

                }
                else {
                    JOptionPane.showMessageDialog(null, "Wrong");
                }


            }
        });
        btnEnter.setBounds(160, 47, 99, 23);
        frame.getContentPane().add(btnEnter);
    }
}

Hope this helps.

Thread Status:

Not open for further replies.
  1. So i am programming a plugin for a server everything was going fine, no errors, until i got this:

    Syntax error, insert «} » to complete ClassBody

    at the bottom of the code, i will show you the code. (Yes, i am posting posts like this maybe all the time, but every post of mine is having it’s own specific problem.)

    package me.NordisKFail;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class GoliChat extends JavaPlugin implements JavaListener{
       
        public void onEnable() {
            getLogger().info(ChatColor.GRAY + "[" + ChatColor.DARK_AQUA + "GoliChat" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "GoliChat er paa. :) (GoliChat av NordisKFail)");
        }
    
        public void onDisable() {
            getLogger().info(ChatColor.GRAY + "[" + ChatColor.DARK_AQUA + "GoliChat" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "GoliChat stenger naa, hvis den ikke skulle det kontakt NordisKFail. :)");
        }
       
        public boolean onCommand (CommandSender sender, Command cmd, String label, String[] args) {
            Player player = (Player) sender;
            return true;
           
            if(cmd.getName().equalsIgnoreCase("cc")){
                if (player.hasPermission("eZChat.CC")) {
                   
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage("");
                    Bukkit.broadcastMessage(ChatColor.YELLOW + "Chatten din ble vasket opp");
                   
            }
           
            if(cmd.getName().equalsIgnoreCase("globalmute")){
                if(player.hasPermission("golichat.globalmute")) {
                   
                }
            }
                   
           
        }
       
    }
    

    Please don’t post posts that doesen’t have to do anything with the topic and don’t say that i can’t begin with coding yet before i have really studied «Java» for a long time. :)

  2. @NordisKFail
    http://www.tutorialspoint.com/java/

    —Optional—

    Class cast exception will be thrown once command is not ececuted by a player.

    Use a loop.

    Still that? where does that come from? does it work?

  3. You can’t code bukkit plugins if you don’t know java. This is a java syntax error
    You’re missing one bracket.

    Please learn java, as having a good understanding of brackets will help fix this error

  4. *Ignoring that you said that i needed to learn more*

    And where would i put the «missing» bracket?

  5. You must learn java before learning bukkit anyways, You must put return true at end of code whereas you have put it under onCommand. Following is a fixed code.

     public void onEnable() {
               getLogger().info(ChatColor.GRAY + "[" + ChatColor.DARK_AQUA + "GoliChat" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "GoliChat er paa. :) (GoliChat av NordisKFail)");
           }
        
           public void onDisable() {
               getLogger().info(ChatColor.GRAY + "[" + ChatColor.DARK_AQUA + "GoliChat" + ChatColor.GRAY + "] " + ChatColor.YELLOW + "GoliChat stenger naa, hvis den ikke skulle det kontakt NordisKFail. :)");
           }
        
           public boolean onCommand (CommandSender sender, Command cmd, String label, String[] args) {
               Player player = (Player) sender;
            
            
               if(cmd.getName().equalsIgnoreCase("cc")){
                   if (player.hasPermission("eZChat.CC")) {
                    
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage("");
                       Bukkit.broadcastMessage(ChatColor.YELLOW + "Chatten din ble vasket opp");
                    
               }
            
               if(cmd.getName().equalsIgnoreCase("globalmute")){
                   if(player.hasPermission("golichat.globalmute")) {
                    
                   }
               }
               }
                return true;
           }
    } 
  6. @CoolGamerXD Best not to spoon feed people but it’s good you didn’t fix the rest of his code only his bracket.

  7. @NordisKFail Okay ignore @Neonix or me, but do not wonder why people will ignore you afterwards. As i mentioned in your previus thread, but it wasnt clear obviusly, java is a Requierment for bukkit. Its like saying «i want to build a house without foundations» it will all be ok up untill a certain height where everything will colapse.
    So there are some key reasons why you SHOULD learn java before bukkit:
    1. to be able to understand what does what.
    2. to fix minor issues in an instant rather than have to wait for someone to solve it for you.
    3. to be able to add new features! (You have no idea how many features you can add even with the basic java knoledge)
    4. to make your code safe, relyable, readable, efficient ect.
    5. to save yourself time! your last question-thread took arround a day to be solved.
    6. to broaden your prospects! java is not just bukkit! its an awesome Object-Oriented language working on most well known operating systems.
    7. to be in a position to understand code and how it works!

    And lets consider that java is a fairly simple language especially the basics! for me personally it took arround a month to gain the basic knowledge and i am not the easyest learning person in the globe.
    Lastly we will be here to help with any problem you face along the way of learning java, What we wont be doing (or so i want to belive) is to give you the answer ready on a plate.
    —-

    @CoolGamerXD i don’t think that spoonfeeding will help the op improve in any shape or form or pinpoint what is wrong and why. :3

    Heh nice one!

  8. I think there should be a simple quiz for java knowledge to register in this forum :p

  9. @FisheyLP Sounds nice but there is always the internet out there holding an answer for almost every question D:

  10. @mine-care The people that have extensive knowledge on java, could probably make that pretty easily.

    If this was a program…

  11. @mine-care

    A quiz to test your programming knowledge.

    I think I tagged the wrong person.

  12. Try it out :p

  13. Well that’s nice, guess I can ignore helping on this thread

  14. It would be better if someone would help me with my question!

  15. Offline

    timtower


    Administrator

    Administrator

    Moderator

    @NordisKFail You have a return in your code with code behind it, the code behind it will never run.
    And again: you aren’t closing a certain if statement in your code, find it, close it.

    It is basic java and has nothing to do with Bukkit. Locked


    vhbob and 1Rogue like this.

Thread Status:

Not open for further replies.

Share This Page


Bukkit Forums

Introduction: Basic Java Debugging

This instruction guide covers a basic step by step check for Java error handling. This guide does not provide any assistance in setting up java programming software and expects that you have already accomplished this task ahead of time. For the best use of this guide, come back to it whenever an error occurs that you are uncertain about and check through the 8 common possibility’s until you are either met with a solution or reach the end. Keep in mind, these examples are all relatively basic and are meant for beginner support.

Before you begin checking through each possible solution, take a look at the error that Java is notifying you with. Each step will begin by showcasing the error that it is associated with.

Step 1: ​“Syntax Error, Insert “;” to Complete BlockStatements”.

This is the most basic of Syntax errors, it simply means you forgot a semicolon at the end of your statement. All declaration and expression statements will end with a semicolon. In some other instances such as with if, else, and for statements you will not need to place the semicolon.

Step 2: “cannot Be Resolved to a Variable”, or “insert VariableDeclarators”

This Syntax error occurs when you are attempting to use a variable without having created it first or provided it a data type. Simply add the data type that is associated with your variable, examples could be “int”, “boolean”, “char”, and “double”.

Step 3: “insert “}” to Complete ClassBody»

Our next Syntax error has to do with curly bracket. You will normally see the error occur when you’ve missed either one or both curly brackets. If you are missing both you will see the error, “insert “ClassBody” to complete ClassDeclaration». If only one is missing you will either see the error, “insert “}” to complete ClassBody» or “{ expected after this token”. The errors will normally occur on the line were the curly bracket can be placed to provide a fix.

Step 4: Infinite Loop

We now look at a case where an error will most likely not be provided by the Java client. This occurs when you have a loop such as a while loop or a for loop that cycles infinitely. There is no simple answer to the solution because each person’s code will vary but trying to add a manual supplementary limit within the code should be the primary goal. After that attempt to figure out why your code was unable to meet your loops break condition?

Step 5: “cannot Be Resolved to a Type”

This Syntax error has to do with imports. Whenever we want to use an API from another class, we must import that class to the current one. A common occurrence for this is the use of the Scanner function, in order to use it you must import the “java.util.Scanner” class. Keep in mind this is only an example.

Step 6: “The Method “” Is Undefined for the Type”

This Syntax error occurs when we forget the class name during a method call. The primary example for this would be whenever we attempt to print. If you’re someone who’s coming off of a language that uses a simple print() function then this can occur frequently. You will instead want to use System.out.print() or System.out.println(). This will always occur during method calls.

Step 7: “string Literal Is Not Properly Closed by a Double-quote”

This Syntax occurs when we are using Strings. The problem has to do with an open but not closed String. It is always marked on the line where it occurs and is fixed by placing that second double quotation. As a side note, if you attempt to use single quotations for Strings that will also result in an error “invalid character constant”.

Step 8: “return Type for the Method Is Missing”

The last Syntax worth mentioning is the method return type and missing return. The “return type for the method is missing” occurs when you have a method that attempts to return something while missing the specification of that type in the method signature. The error will occur in the signature and is usually a very fast solve. When it comes to the “method must return a result of type” error you just need to make sure you return something with that type.

Step 9: Extra Assistance

If you were unable to find a fix for your error, then consider attempting one of these following options. Copy Java’s note on the error that occurred and attempt to find a solution by pasting it into some web search. Search for some more advanced or explicit Java error handling guides. Lastly, if none of these options helped and you have the time to spare, attempt to post your question on a support forum such as Stackoverflow. You will commonly get a response fix with an explanation as to why the error occurred in the first place.

Be the First to Share

Recommendations


posted 9 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

I WANT THIS PROGRAM TO get 3 numbers and show the biggest one.

what is wrong?

here is what the program says:

Exception in thread «main» java.lang.Error: Unresolved compilation problem:

This method requires a body instead of a semicolon

at main.main(main.java:4)

thanks

Ben

author & internet detective

Posts: 41506

Eclipse IDE
VI Editor
Java


posted 9 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Ben,

Welcome to CodeRanch! I added code tags to make the post easier to read.

It looks like you are missing braces. For example:

The braces are how Java knows which parts of the code go together. In other words, where things like methods and classes start and end. They are optional around if statements when there is a single statement. But they aren’t optional all over.

ben istaharov

Greenhorn

Posts: 9


posted 9 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Here it is and its still not working

public class main {

public static void main(String[] args) {

int Num1, Num2, Num3;

int temp;

Num1 = BasicIO.ReadInteger(«Enter First Number: » );

Num2 = BasicIO.ReadInteger(«Enter Secend Number: » );

Num3 = BasicIO.ReadInteger(«Enter Third Number: » );

if (Num1 >= Num2 ) temp = Num1; else temp = Num2;

if (Num3 >= temp ) System.out.println(«Biggest Num: » + Num3);

else

System.out.println(«Biggest Num: » + Num3); } }

Exception in thread «main» java.lang.Error: Unresolved compilation problem:

Syntax error, insert «}» to complete ClassBody

at main.main(main.java:18)


posted 9 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

ben istaharov wrote:

Exception in thread «main» java.lang.Error: Unresolved compilation problem:

Syntax error, insert «}» to complete ClassBody

at main.main(main.java:18)

One of the features of IDEs, is that it allows you to run programs that don’t compile properly. Please don’t use this feature. Make sure everything compiles before running them.

So, please compile the program, and show us the error from the compiler — and not the error generated while running a program that didn’t compile.

To answer your question… Do you have balanced curly braces? For each open brace, you need a close brace.

Henry

ben istaharov

Greenhorn

Posts: 9


posted 9 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

where is the compiler button?

i used to pclick the run button before.

i have 4 braces.

Jeanne Boyarsky

author & internet detective

Posts: 41506

Eclipse IDE
VI Editor
Java


posted 9 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

What IDE are you using?

lowercase baba

Posts: 13086

Chrome
Java
Linux


posted 9 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

try compiling it from the command line. This is something you need to learn how to do.

The code you posted most recently looks good to me — I can’t compile it because I don’t have your BasicIO class available, but if i comment out the lines, it does compile and run. If you are getting and error about braces, then you are not compiling the code you think you are.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors


posted 9 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

ben istaharov wrote:where is the compiler button?

i used to pclick the run button before.

i have 4 braces.

Yeah, this is one of the reasons why we don’t recommend starting with an IDE (for beginners) — it hides access to the compiler from you. The problem with the compile error message at run time, is that it is the error first encountered while running the program. It may not be the first error encountered by the compiler. It may be one of the later errors — where the compiler is already confused, and generating incorrect error messages.

Running the java compiler directly, you can quickly see which is the first compiler error. With the IDE, it is probably best to use the editor. Go to the top of the file, and slowly work your way down, until you hit the first red flag. There should be a tooltip that will show the error. BTW, I am assuming Eclipse, but other IDEs should be similar.

Henry

jQuery in Action, 3rd edition

Понравилась статья? Поделить с друзьями:
  • Syntax error insert finally to complete blockstatements
  • Syntax error incomplete input
  • Syntax error in update statement
  • Syntax error in sql statement expected identifier sql statement
  • Syntax error in sql expression