answersLogoWhite

0

In java, the String object has a compareTo() method. The method returns an int. If the int is less than zero, the first string is less than the second. If the int is greater, the first is greater than the second. If the int is zero, the two strings are equal.

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

How do you campaire Strings in java?

String class in Java has an 'equals' method that can be used to compare strings.


What is the defualt value for String in java?

The default value for objects is null; I believe this would apply to a String, too, since Strings are objects.


Write a program in java to display a string message using Servlets?

i dont no string for servlate


Can vector store string values in java programming?

A Vector can store any objects, so yes.


What is special about the lang and string packages for the language Java?

The string can never be modified, they are immutabile. If you think a string is modified, it is actually a new creation. It's basically a conversion of other objects.


Write a java program to initialize array of string with the days of the week?

final String[] days = new String[] {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};


How to write A Java program to print number of digits in a given number?

One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.


How do we declare objects?

In Java, write the name of a class, followed by a variable name. For example:String myName;This won't actually create the object; you also need to create the object:myName = new("Hi, it's me.");These two parts (declaration, and object creation) can be combined:String myName = new String("Hi, it's me.");(In the case of a String, in Java you can just assign a quoted string, instead of using the new operator. However, I wanted to show the general syntax for object creation, that works for other kinds of objects too.)In Java, write the name of a class, followed by a variable name. For example:String myName;This won't actually create the object; you also need to create the object:myName = new("Hi, it's me.");These two parts (declaration, and object creation) can be combined:String myName = new String("Hi, it's me.");(In the case of a String, in Java you can just assign a quoted string, instead of using the new operator. However, I wanted to show the general syntax for object creation, that works for other kinds of objects too.)In Java, write the name of a class, followed by a variable name. For example:String myName;This won't actually create the object; you also need to create the object:myName = new("Hi, it's me.");These two parts (declaration, and object creation) can be combined:String myName = new String("Hi, it's me.");(In the case of a String, in Java you can just assign a quoted string, instead of using the new operator. However, I wanted to show the general syntax for object creation, that works for other kinds of objects too.)In Java, write the name of a class, followed by a variable name. For example:String myName;This won't actually create the object; you also need to create the object:myName = new("Hi, it's me.");These two parts (declaration, and object creation) can be combined:String myName = new String("Hi, it's me.");(In the case of a String, in Java you can just assign a quoted string, instead of using the new operator. However, I wanted to show the general syntax for object creation, that works for other kinds of objects too.)


What are some example for string formatting in Java?

There are lots of examples of string formatting in Java. It can be difficult at times. Some of these examples are, but are not limited to; align, string, format, and JAVA.


Write a java program to count the space from the given line?

.... String line = "This is example program with spaces"; String[] tokens = line.split(" "); System.out.println(tokens.length-1); .......


Write a program to change the case of the given string?

This functionality is already in Java. String.toLowerCase() and String.toUpperCase() will take care of it for you.


Creating an object in java?

You use the "new" operator, for example: MyClass x = new MyClass();