Monday, 25 December 2017

WAP to print the second last word of given sentence

WAP to print the second last word of given sentence , WAP to print the second last word of given sentence in java, print the second last word of given sentence,

package com.dashzin.prog;
import java.util.Scanner;
public class Secound_Word_Of_String {
public static void main(String[] args) {

Scanner cs=new Scanner(System.in);
System.out.println("enter the String");

String st=cs.nextLine();

String word[]=st.split(" ");
String last=word[word.length-2];

System.out.println(last);

System.out.println("------solited string are------");
for(String as:word){
System.out.println(as);
}
}
}




DashZin

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

5 comments: