Astonishing Java String Programs part-III
Java String Programs part-III: solved Java program for ICSE Class 10 Computer Applications with complete BlueJ code, explanation and sample output.
Java String programs: They are asked for more than 15 marks in the ICSE computer application class X
For java videos click
http://www.youtube.com/trushnatej
Write a program To extract letters of a word(String)
For example if the string is programs, the output will be p, r, o ,g, r, a, m in different lines.
import java.io.*;
class Extract
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a word");
String wrd= br.readLine();
int len=wrd.length();
for (int i=0;i<len;i++)
{
char ch=wrd.charAt(i);
System.out.println(ch);
}
}
}Output:-
Enter a word
Computer
C
o
m
p
u
t
e
r
Write a program to extract words of a sentence.
import java.io.*;
class ExtractWord
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a sentence");
String str= br.readLine();
int len=str.length();
int d=0;
for (int i=0;i<len;i++)
{
char ch=str.charAt(i);
if(Character.isWhitespace(ch))
{
String temp=str.substring(d,i);
d=i;
System.out.println(temp.trim());
}
}
}
}Enter a sentence
This is computer program
This
is
computer
program
For more string programs
Beautiful String programs in java part-II
Related Posts
Continue learning with these related articles

String Methods in Java for ICSE Class 10: 25 Output Questions with Answers
ICSE Class 10 Computer Applications practice on String class methods: length, charAt, indexOf, lastIndexOf, substring, replace, trim, compareTo, equals and more, with 25 board-style output questions and step-by-step answers.

Special Number Programs in Java for ICSE: Armstrong, Spy, Neon, Disarium, Pronic and More
Every special number asked in ICSE Computer Applications – prime, perfect, Armstrong, palindrome, automorphic, neon, spy, Niven, duck, buzz, Disarium, special and pronic numbers – with definitions, examples and one complete Java program that checks them all.

Math Library Methods in Java for ICSE Class 9 (with Outputs)
ICSE Class 9 Computer Applications notes on the Java Math class: sqrt, cbrt, pow, abs, max, min, ceil, floor, round, rint and random, with return types, tricky negative-number outputs and Java expressions for formulas.