Created
January 29, 2019 08:10
-
-
Save vignarajj/c4987ad8c968ebbfa6ab852713d20c20 to your computer and use it in GitHub Desktop.
Print the characters in String not repeated.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package javaproblems; | |
import java.util.Scanner; | |
public class PrintDiffChar { | |
public static void main(String[] args) { | |
String text; | |
int count; | |
char ch; | |
Scanner SC=new Scanner(System.in); | |
System.out.println("Type your words : "); | |
text = SC.nextLine(); | |
//converting string into upper case | |
text = text.toUpperCase(); | |
count = 0; | |
System.out.println("Following characters are used in the input text "); | |
for ( ch = 'A'; ch <= 'Z'; ch++ ) { | |
int i; //character index in string | |
for ( i = 0; i < text.length(); i++ ) { | |
if ( ch == text.charAt(i) ) { | |
System.out.print(ch + " "); | |
count++; | |
break; | |
} | |
} | |
} | |
System.out.println("\nTotal number of different characters are " + count); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment