Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Substring Method

807607Nov 10 2006 — edited Nov 10 2006
Hi,
I am doing a project in java which I won�t go in detailed about at the mo. So the question is how I can use the substring method to compute substrings of a string, which is not in a string format. I will show the code to allow you to make sense of the problem.
public class Names{



String Name;


 	public Names (String notation)

 		{

			Name = notation;

		}





String sub = Name.substring(0,3);

public String Suit ()


			{
				double club;


				if (sub == "Joe")
				{
				}

				return "Bloggs";



			}

}
As you can see from the code I want to use the variable �Name� as a string in the substring method.

Can anyone tell me if this correct? Or can it be done?

NP:
I will be using a NamesTest.java to enter the text Joe so that notation = �Joe� and
Name = notation.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 8 2006
Added on Nov 10 2006
23 comments
257 views