Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-11-2012, 08:36 PM   PM User | #1
dannyboi
New Coder

 
Join Date: Jul 2012
Location: NYC
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
dannyboi is an unknown quantity at this point
problem with logical operators

import javax.swing.JOptionPane;

public class Main {





public static void main(String[] args) {
int switch1 = 10;
int switch2 = 20;
}
if(((switch1==1)&&(switch2==-1))||((switch1!=1)&&(switch2!=-1)))
JOptionPane.showMessageDialog (null, "Trouble, the switches are the same!");

else

JOptionPane.showMessageDialog(null, "Ok the switches are different.");


}
}
}


The problem here is that the compiler keeps on saying that I need a bracket. Alternately, I add one, and the whole code just...is awash in red lines. Help?

Last edited by dannyboi; 08-12-2012 at 03:09 AM..
dannyboi is offline   Reply With Quote
Old 08-11-2012, 10:18 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
You're missing a brace, not a bracket.
And where is "switch1" and "switch2" defined?
Fou-Lu is offline   Reply With Quote
Old 08-12-2012, 03:09 AM   PM User | #3
dannyboi
New Coder

 
Join Date: Jul 2012
Location: NYC
Posts: 23
Thanks: 1
Thanked 0 Times in 0 Posts
dannyboi is an unknown quantity at this point
Ok, I have defined switch1 and switch2, now what?
dannyboi is offline   Reply With Quote
Old 08-12-2012, 12:39 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
You cannot just randomly add a location to put a closing brace.
I think you better start here, and start under the trails covering the basics section: http://docs.oracle.com/javase/tutorial/
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Tags
java, java programming

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:40 AM.


Advertisement
Log in to turn off these ads.