Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Small Syntax Error

syntax syntax error

  • Please log in to reply
4 replies to this topic

#1 Hunter100

Hunter100

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 292 posts
  • Programming Language:C, C++, PHP, Python, Delphi/Object Pascal, Assembly
  • Learning:Python, Assembly, Bash

Posted 27 March 2010 - 06:36 PM

Hello all,

This is probably a mistake I missed (I'm relativley new to Java) but this is what it says:
[SIZE=1] [/SIZE]
[LEFT]Multiple markers at this line
- Syntax error, insert "}" to complete 
ClassBody[/LEFT]
- Debug Current Instruction Pointer

The only thing on that line was a } at the end of the program!

Thanks to any help.
  • 0

#2 bobdark

bobdark

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 155 posts

Posted 27 March 2010 - 09:52 PM

Post your whole code so you can get a proper answer, but it seems you're lacking some brackets.
  • 0

#3 so1i

so1i

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 297 posts

Posted 28 March 2010 - 09:45 AM

It'll be because a bracket is missing, where it should be to close one part of your code. Like bobdark says, if you post all your code, we could find it more easily. However my advice would be just to check the amount of opening '{' and closing '}' and make sure they are the same.
  • 0

#4 Hunter100

Hunter100

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 292 posts
  • Programming Language:C, C++, PHP, Python, Delphi/Object Pascal, Assembly
  • Learning:Python, Assembly, Bash

Posted 28 March 2010 - 10:51 PM

I'm a beginner, so basically it tests a number in the variable passCodeForLock if it is 15671 then it allows you to write to a text file (not complete so it hasn't got the text file thing). BTW How do you write to a text file in Java?

Thanks.

[B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]
[LEFT]import[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] java.util.Scanner;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055][LEFT]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]class[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Password_Lock {

[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]public[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]static[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]void[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] main(String[] args) {
Scanner passCodeForLock = [/SIZE][B][U][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]new[/B][/U][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (System.in);
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]int[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] scrambledValue = passCodeForLock - 3 + 9;

System.out.println([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Enter your assigned password:"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);


[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]if[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (passCodeForLock == 15671){
System.out.println([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Access Granted..."[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
}
[/SIZE][B][SIZE=2][COLOR=#7f0055][SIZE=2][COLOR=#7f0055]else[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] {
System.out.println ([/SIZE][SIZE=2][COLOR=#2a00ff][SIZE=2][COLOR=#2a00ff]"Access Denied"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]);
}[/LEFT]
[U]}
[/U][/SIZE]

  • 0

#5 so1i

so1i

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 297 posts

Posted 29 March 2010 - 01:24 AM

You are missing a } at the end of your code. You need one to close the class, and one to close the Main() method.

Here is an example code for writing to a file:
try {
    BufferedWriter out = new BufferedWriter(new FileWriter("outfilename"));
    out.write("aString");
    out.close();
} catch (IOException e) {
}

And here is the tutorial from Sun:
File Operations (The Java™ Tutorials > Essential Classes > Basic I/O)
  • 0





Also tagged with one or more of these keywords: syntax, syntax error

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download