Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Answers Viewqa Java-Beginners Comparing strings

View Questions and Answers by Category


Have Programming Question? Ask it here!

Comparing strings
2 Answer(s)      6 years and 7 months ago
Posted in : Java Beginners

View Answers

August 12, 2008 at 4:15 PM

Hi friend,

import java.lang.*;

public class CompareString{
public static void main(String[] args) throws IOException{
System.out.println("String are equal and not equals");
BufferedReader item = new BufferedReader(new InputStreamReader(;
System.out.print("Enter First String:");
String item1=item.readLine();
System.out.print("Enter Second String:");
String item2=item.readLine();
char c1=item1.charAt(0);
char c2=item2.charAt(0);
char c3=item1.charAt(1);
char c4=item2.charAt(1);

if( item1.equals(item2)){
System.out.println("The given string is equals.");
System.out.println("The given String is not equals.");


Read for more information.



August 12, 2008 at 5:37 PM

hai frnd......
i think this would help u....

class Substring
public static void main(String a[])throws Exception
String str,sub;
int i=0,k=0;
BufferedReader br;
br=new BufferedReader(new InputStreamReader(;
System.out.println("Enter the String: ");

System.out.println("Enter the subString: ");


System.out.println("The number of times is: "+k);

inform me if it works...

thanks and regards

Related Tutorials/Questions & Answers:
Iphone Comparing Strings
Iphone Comparing Strings  Hi, I am very new in the mobile application programming. I have trying to develop a small application for IPhone SDK Comparing Strings. Could any one suggest or provide any examples topics iphone sdk
Comparing strings - Java Beginners
Comparing strings  Can anyone help with finding the number of time(s) a substring appears in a string? The code I've written can get it once and after that cannot continue to the end of the string.  Hi friend, import
iPhone SDK Comparing Strings
of comparing strings in iPhone sdk programs. The == operator only compares the pointers, but instead we are comparing the the actual strings.  Hope the above...In this section I will show you how you can compare the two strings in your
Comparing Strings in a Locale-Independent Way
Comparing Strings in a Locale-Independent Way In this section, you will learn how to compare strings in a locale independent way. For handling strings, java.text.* package provides the class Collator. This class performs locale
strings  difference between the strings in java and c
strings  write a program in java to accept two strings as command line arguments and perform the following operations-: 1) compare the strings 2... is an example which accept two strings as command line arguments and perform
will contain strings which is separated by ",". From the main method invoke
strings   read sentence and convert all the word into capital case like camelcase   Hi Friend, Try the following code: import java.util.*; class ConvertWordsIntoUpperCase { public static String toCamelCase(String
Comparing tables
Comparing tables  How to compare two or more tables in the Mysql database using jdbc
Comparing arrays not working correctly?
Comparing arrays not working correctly?  Comparing arrays not working correctly
comparing dates objective c
comparing dates objective c  Comparing two different dates in Objective C.   if( [date isEqualToDate:otherDate] ) NSLog(@"%@ is equal to %@",date,otherDate);   Objective C NSString Date Example
compare two strings in java
) { System.out.println("The two strings are the same."); } } } Output: The two strings are the same. Description:-Here is an example of comparing two strings in java  How to compare two strings in java
Comparing XML with HTML
Comparing XML with HTML XML and HTML are both designed for different purposes. Although they have some similarities in markup syntax but they are created for different types of goals. XML is not at all the replacement of HTML
Strings in PHP
Strings in PHP  Hi, I am beginners and want to know about strings in PHP and different ways to print a string. Can someone help me in this regards?   Following tutorials will help you in details about strings in PHP
strings concatnation
strings concatnation  in string1 "123456 ABC DEF...",IN string2 "raveen". iwant to add string2 after 123456 in the first string based on index number.i need logic
strings in java
strings in java  please explain me the flow of this program..not able to execute correctly n wats the use of clone public class Strclone { public static void main(String args[]) { String s=new String("a"); String s1
strings 20june
strings 20june  please explain me the flow of this program..not able to execute correctly n wats the use of clone public class Strclone { public static void main(String args[]) { String s=new String("a"); String s1 = "Hello
programes on strings
programes on strings   a. write a program to copy one array to another array using System.arrayCopy() method. b. write a program to check whether entered string is palindrome or not.   Have a look at the following link
String comparison example
:- There are many comparison operators for comparing strings like <, <=, !=, ==, =>, and >. Action script  compare strings on the character code value...; operator for compare two strings. Example:- <?xml version="
comparing arraylist of an multi dimensional arraylist
comparing arraylist of an multi dimensional arraylist  can anyone help me in solving the following issue: actually i have an arraylist called dany under which there are 89 more arraylist.each of them contains some i
Switch Statement with Strings in Java
Switch Statement with Strings in Java  Switch Statement with Strings in Java
split strings in php
split strings in php  how can i split strings in word pair in PHP