This week's book giveaway is in the
Agile and other Processes
forum.
We're giving away four copies of
The Mikado Method
and have Ola Ellnestam and Daniel Brolund on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Certification
»
Programmer Certification (SCJP/OCPJP)
Author
about if-else
ming ming
Ranch Hand
Joined: May 17, 2006
Posts: 54
posted
Jun 14, 2006 04:12:00
0
import java.util.*; public class First { public static void main(String[] args) { Scanner scan=new Scanner(System.in); String name=null; System.out.println("Please insert a name"); name=scan.nextLine(); if(name=="Jason"){ System.out.println("Jason"); } else if(name=="Tomm"){ System.out.println("Tomm"); } else if(name=="Robert"){ System.out.println("Robert"); } } }
In the above code y when i enter the name "Jason", it will not display the name???
wise owen
Ranch Hand
Joined: Feb 02, 2006
Posts: 2023
posted
Jun 14, 2006 04:18:00
0
if ("Jason".equals(name)){
...
}
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: about if-else
Similar Threads
Java Array search and print
How to check entered value is of which primitive type?
err get and set methods and scanner class / JOptionPane
is there a quicker way to read in input besides bufferedreader?
looped menu
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter