Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

New Programmer is Newwww...

Name: Anonymous 2008-04-25 1:16

Before you is a simple script of Java.  For some reason, whenever I put in "pie" I receive the "else" response.  Why?!  I know I'm overlooking something... but I'm just not seeing it

import java.util.Scanner;

class IfElse {
   
        public static void main(String args[])  {
           
            Scanner myScanner = new Scanner(System.in);
            String UserInput;
           
            System.out.println("Pie or Cake?");
            UserInput = myScanner.next();
           
            if (UserInput == "pie")  {
                System.out.println("Shit yeah, pie!!!");
            } else {
                System.out.println("FUCK, I love cake");
            }
        }
    }

Anyone?

Name: Anonymous 2008-04-25 1:18

strings comparison is not done via ==, try someString.equals("pie");

Anon delivers ;)

Name: Anonymous 2008-04-25 1:19

newlines?

Name: Anonymous 2008-04-25 1:22

wat? newlines wat?

Name: Anonymous 2008-04-25 1:25

if (UserInput.equals("pie"));  {

Like this?  I tried this and it gave me an "else with no 'if'"  error.

Name: Anonymous 2008-04-25 1:28

>>5
Blatant troll is blatant.

Do better next time, kthx.

Name: Anonymous 2008-04-25 1:28

"pie\n", "pie\r\n", or maybe chomp(UserInput) == "pie"?

Name: Anonymous 2008-04-25 1:29

>>5
Get rid of the semicolon.

P.S. It is clear to ME that you will never achieve SATORI.

Name: Anonymous 2008-04-25 1:34

>>8

Well, your advice worked, so thanks I guess...

Not sure what SATORI is.  Been programming for exactly 48 hours.  Please have mercy on teh noob :(

Name: Anonymous 2008-04-25 2:05

>>9

>>8
here. I haven't had an erection in decades.

Name: Anonymous 2008-04-25 2:12

>>1
/pr/ is that way ――――――――►

Name: Anonymous 2008-04-25 2:28

Name: Anonymous 2008-04-25 3:00

People really need to lurk.

Name: Anonymous 2009-07-12 7:25

as are as same me from open looked from viewed define  we are more Billion 100%  100% Over

Name: Sgt.Kabukiman䖉 2012-05-22 23:22

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List