stringpractice

1
String: 1- WAP to remove all the spaces from a string given by user. (Ex “ I am reading Java ”----- “IamreadingJava”) 2- WAP to count the frequency of all the character which are present in a given string.(Ex“java needs practice”--- ) 3- WAP to check weather a string given by user is a palindrome or not.(Without use of reverse method of StringBuffer class) 4- Write a method that returns second index position using the following header: static int position(String s, char c) 5- Write a method that returns a sorted string using the following header: int location(char c) which return the index position of first occurance a character which is present in the string else return -1.(without use of indexOf() ) 6- Write a method that returns a sorted string using the following header: public static String sort(String s) (Ex.sort("acb") ----abc. Write a test program that prompts the user to enter a string and displays the sorted string.

Upload: shivamgupta

Post on 21-Dec-2015

224 views

Category:

Documents


0 download

DESCRIPTION

You can practice Strings in Java

TRANSCRIPT

Page 1: Stringpractice

String:

1- WAP to remove all the spaces from a string given by user.

(Ex “ I am reading Java ”----- “IamreadingJava”)

2- WAP to count the frequency of all the character which are present in a

given string.(Ex“java needs practice”--- )

3- WAP to check weather a string given by user is a palindrome or

not.(Without use of reverse method of StringBuffer class)

4- Write a method that returns second index position using the following

header: static int position(String s, char c)

5- Write a method that returns a sorted string using the following header:

int location(char c) which return the index position of first occurance a

character which is present in the string else return -1.(without use of

indexOf() )

6- Write a method that returns a sorted string using the following header:

public static String sort(String s) (Ex.sort("acb") ----abc.

Write a test program that prompts the user to enter a string and displays

the sorted string.