Write a program to input a sentence and print each word of the string along with its length in tabular form.
Answers
Answered by
2
Explanation:
public class Quorastring {
private String strdet="Welcome To The Wolrd of Java String";
public static void main(String[] args) {
Quorastring obj=new Quorastring();
String str[]=obj.strdet.split("\\s");
System.out.println("Word" +"\t"+"Length");
//System.out.println(str[0]);
for(String a:str){
System.out.println(a+"\t"+a.length());
}
}
}
Similar questions