Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws IOException {
        String data, answer = "";
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("Enter any String : ");
        data = br.readLine();
        char[] findupper = data.toCharArray();
        for (int i = 0; i < findupper.length; i++) {
            if (findupper[i] >= 65 && findupper[i] <= 91) // ascii value in between 65
                                                          // and 91 is A to Z
            {
                answer += findupper[i]; // adding only uppercase
            }
        }
        System.out.println("Answer : " + answer);
    }
}