File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes string management Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "string management" Watch "string management" New topic

string management

Pradyut Bhattacharya
Ranch Hand

Joined: Aug 12, 2004
Posts: 63
hi friends,

i have a problem on managing input strings on a program.

i have to make a program in which on hitting "enter" or a particular word the program should show some output.

the code of my program: -

import java.lang.*;
import java.util.*;

public class test

public static void main(String args[])
//ctrl-c to terminate the program
InputStreamReader keyreader = new InputStreamReader(;
BufferedReader bfreader = new BufferedReader(keyreader);
System.out.println("Enter the element: ");
String name = bfreader.readLine();
if (name == "test")
System.out.println("this is a test");
else if (name == "")
catch(Exception e)

here on giving the word test or simply hitting enter the program does not show the results as required.

any help

Joyce Lee
Ranch Hand

Joined: Jul 11, 2003
Posts: 1392
Hi Pradyut,

You must use the equals() method to compare the String content.

[ November 15, 2004: Message edited by: Joyce Lee ]
I agree. Here's the link:
subject: string management
Similar Threads
Help with BufferedReader
linked list i/o program
request for better implementation of the program
linked list i/o program
string management