Results 1 to 7 of 7
Like Tree2Likes
  • 2 Post By jammas615

Thread: if statements Error?

  1. #1
    dharav is offline Member
    Join Date
    Dec 2011
    Posts
    28
    Rep Power
    0

    Default if statements Error?

    I do not know how to write this properly Can anyone edit it please theres a error.
    Java Code:
    Java Code:
    package Samurai;
    import java.util.*;
    import javax.swing.*;
    public class Samurai {
    
    	/**
    	 * @param args
    	 */
    	public static void main(String[] args) {
    		SwingUtilities.invokeLater(new Runnable() {
    			public void run()
    			{
    				JFrame frame = new JFrame("Samurai Game : By Dharav");
    				frame.setSize(500,400);
    				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    				frame.setVisible(true);
    			}
    		});
    		
    		
    		//VARIABLES ONLY SECTION
    		
    		String nameofwarrior,cityname,hit;
    		
    		int nameofcity,cityexplore,i,k,villan,boss;
    		
    	boss=(int) (Math.random()*10);
    		
    		if (boss==1||10)
    		{
    			System.out.println("Hey");
    		}
    	}}
    Last edited by JosAH; 01-15-2012 at 10:56 AM. Reason: added [code] ... [/code] tags

  2. #2
    jammas615 is offline Senior Member
    Join Date
    Jul 2011
    Location
    Melbourne, Victoria, Australia
    Posts
    155
    Rep Power
    4

    Default Re: if statements Error?

    What exactly is the error you're getting? Don't expect to get an answer without telling us the problem.
    Fubarable and AndreB like this.

  3. #3
    AndreB's Avatar
    AndreB is offline Senior Member
    Join Date
    Dec 2009
    Location
    Stuttgart, Germany
    Posts
    114
    Rep Power
    0

    Default Re: if statements Error?

    Quote Originally Posted by jammas615 View Post
    What exactly is the error you're getting? Don't expect to get an answer without telling us the problem.
    this!

    and you should change (boss==1||10) to (boss==1 || boss==10)
    "There is no foolproof thing; fools are too smart."
    "Why can't you solve my Problem ?"

  4. #4
    jammas615 is offline Senior Member
    Join Date
    Jul 2011
    Location
    Melbourne, Victoria, Australia
    Posts
    155
    Rep Power
    4

    Default Re: if statements Error?

    I knew that...
    Can anyone edit it please theres a error.
    but he was just asking for an answer without telling anyone his problem.

  5. #5
    AndreB's Avatar
    AndreB is offline Senior Member
    Join Date
    Dec 2009
    Location
    Stuttgart, Germany
    Posts
    114
    Rep Power
    0

    Default Re: if statements Error?

    Quote Originally Posted by jammas615 View Post
    I knew that...

    but he was just asking for an answer without telling anyone his problem.
    yes... maybe there is an misunderstanding

    with "this!" i meant to support your statement. the thread creator should post questions in the right way.
    "There is no foolproof thing; fools are too smart."
    "Why can't you solve my Problem ?"

  6. #6
    iliyapolak is offline Member
    Join Date
    Jan 2012
    Posts
    14
    Rep Power
    0

    Default Re: if statements Error?

    As Andre wrote in his post you must use variable named boss and assign to it value 10.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default Re: if statements Error?

    Quote Originally Posted by iliyapolak View Post
    As Andre wrote in his post you must use variable named boss and assign to it value 10.
    That's not what he wrote.

Similar Threads

  1. error - I think involving my Import Statements
    By Sparky in forum New To Java
    Replies: 2
    Last Post: 02-02-2011, 02:31 PM
  2. if else if statements
    By Allspark in forum New To Java
    Replies: 9
    Last Post: 09-28-2010, 06:50 PM
  3. if else statements
    By sweetpea123 in forum New To Java
    Replies: 4
    Last Post: 04-12-2010, 07:02 PM
  4. age: using if statements
    By yasmin k in forum New To Java
    Replies: 2
    Last Post: 10-04-2009, 09:50 PM
  5. Help with if-else statements
    By porchrat in forum New To Java
    Replies: 4
    Last Post: 03-23-2009, 04:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •