String Class Of Java

Reply

Join Date: Jul 2004
Posts: 16
Reputation: shantuli is an unknown quantity at this point 
Solved Threads: 0
shantuli shantuli is offline Offline
Newbie Poster

String Class Of Java

 
0
  #1
Jul 25th, 2004
hi everyone,
i am very new in java.can anyone help me to do the following problem:

Write a program to do the following using in-built methods in the string class of java.
1) Find the 5th caracter in the string " RUSTIN BOND"
2) Find the index of character "K" in string "KANSAS".
3) Convert the string "hello world" to uppercase.
4) Replace character 'h' with 'b' in the string"humble".


thank you,
regards,
shantuli
Reply With Quote Quick reply to this message  
Join Date: Jun 2003
Posts: 313
Reputation: red_evolve is on a distinguished road 
Solved Threads: 0
red_evolve's Avatar
red_evolve red_evolve is offline Offline
Posting Whiz

Re: String Class Of Java

 
0
  #2
Jul 25th, 2004
Greetings.
This would be of help to you.
Java String api
Have a look at java.lang -> String.
"Study the past if you would define the future" - Confucius
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 55
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: String Class Of Java

 
0
  #3
Jul 26th, 2004
String s;
s.charAt(5);

s.indexOf('K');

String t = s.toUpperCase();

s.replace(h,b);
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 16
Reputation: rickste_r is an unknown quantity at this point 
Solved Threads: 0
rickste_r's Avatar
rickste_r rickste_r is offline Offline
Newbie Poster

Re: String Class Of Java

 
0
  #4
Jul 27th, 2004
Ok, the String class is a very important tool in java. Make yourself famaliar with it.
Go to this Weblink to revise some of its properties.
Weblink

Your code should be simliar to this....
------------------------------------------------------------------------
public static void main(String[] args)
{
/*1) Find the 5th caracter in the string " RUSTIN BOND"
2) Find the index of character "K"in string "KANSAS".
3) Convert the string "hello world"to uppercase.
4) Replace character 'h'with 'b'in the string"humble */

String no1 = "RUSTIN BOND";
String no2 = "KANSAS";
String no3 = "hello world";
String no4 = "humble";

//print out the results

//remember java indicies start at 0
System.out.println("\nCurrent String: " + no1);
System.out.println("The 5th character: " + no1.charAt(4));

//remember java indicies start at 0
System.out.println("\nCurrent String: " + no2);
System.out.println("The index of character k: " + (no2.indexOf("K") + 1) );

System.out.println("\nCurrent String: " + no3);
System.out.println("Convert string to uppercase: " + no3.toUpperCase());

System.out.println("\nCurrent String: " + no4);
System.out.println("Replace character h with b: " + no4.replace('h', 'b'));
}
-----------------------------------------------------------------
Hope that helps! Rickste_r
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC