Javatpoint Logo

programme for print the not duplicate characters?

By: balaji*** On: Thu Jun 21 12:44:13 IST 2018     Question Reputation0 Answer Reputation0 Quiz Belt Series Points0  0Blank User
input:
core java
output:
corejv
Up0Down

 
import java.util.Scanner;

class DuplicateRemover
{
public static void main(String[] args)
{
Scanner sc = new Scanner (System.in);
String s;
char sa[];
System.out.print("Enter a String:");
s = sc.nextLine();
sa = new char[s.length()];
for(int i=0 ; i<s.length(); i++){
sa[i]=s.charAt(i);
}
for(int i=0; i<sa.length; i++){
boolean b = true;
for(int j=0; j<i; j++){
if(sa[i]==(sa[j])){
b = false;
break;
}
else if (Character.isWhitespace(sa[i])){
b = false;
break;
}
}
if(b==true)
System.out.print(sa[i]);
}
}
}
Image Created0Down

By: [email protected] On: Thu Jun 21 21:19:55 IST 2018 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No
 
import java.util.Scanner;

class DuplicateRemover
{
public static void main(String[] args)
{
Scanner sc = new Scanner (System.in);
String s;
char sa[];
System.out.print("Enter a String:");
s = sc.nextLine();
sa = new char[s.length()];
for(int i=0 ; i<s.length(); i++){
sa[i]=s.charAt(i);
}
for(int i=0; i<sa.length; i++){
boolean b = true;
for(int j=0; j<i; j++){
if(sa[i]==(sa[j])){
b = false;
break;
}
else if (Character.isWhitespace(sa[i])){
b = false;
break;
}
}
if(b==true)
System.out.print(sa[i]);
}
}
}
Image Created0Down

By: [email protected] On: Thu Jun 21 21:20:14 IST 2018 Question Reputation0 Answer Reputation0 Belt Series Points0 0User Image
Are You Satisfied :0Yes0No