Monday, 24 January 2022

A) Write a java program to display alternate character from a given string.

 SLIP 4 Q 1

SAVE CODE AS         "Alternatecharfromstr.java"


import java.util.Scanner;

public class Alternatecharfromstr {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    System.out.print
    ("Enter a string :");
    String str = sc.nextLine();
    sc.close();
    for (int i=0;i<str.length();i+=2){ //run only 2 mulriple index
        System.out.print(str.charAt(i)+" ");
    }
    }
}



OUTPUT :



No comments:

Post a Comment

Write a Java program to display given extension files from a specific directory on server machine.

 DOWNLOAD     SLIP14Q2 /** * STEPS TO RUN CODE * Step 01 compile the code * Step 02 run the code * Step 03 give a file directory locatio...