Java program to remove the duplicate charaters in the given String

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

/*Hello Sir Please comment, Is this ok to write following way without using hashset class.*/

package practice5;

public class {

public static void main(String[] args)
{
String str = "hellomate"; // helomat
String newStr ="";
char[] ch = str.toCharArray();
for(char c : ch)
System.out.print(c);
newStr = newStr+ch[0];

for(int i = 1; i<ch.length; i++)
{

boolean isDuplicate = false;

for(int j =0; j<i; j++)
{
if(ch[i]==ch[j])
{
isDuplicate=true;


}


}
if(isDuplicate==false)
{
newStr = newStr+ch[i];
}

}


}


}

sunnygupta
Автор

The JAVA playlist which is in your Channel is for
Software Testers?
Or for
JAVA developers?
I hope you reply Sir

yadojuvennela
welcome to shbcf.ru