Write a java program to remove consecutive duplicates from a string.
For example, "ABBACCD" should return "D".
public static void main(String[] args)
{
String s = "VBBVGGVR";
String temp = "";
boolean pass = true;
while(pass){
pass = false;
for(int i=0;i<s.length();i++)
{
if(i+1<s.length() && s.charAt(i)==s.charAt(i+1))
{
pass = true;
i++;
}
else
{
temp = temp + s.charAt(i);
}
}
s = temp;
temp = "";
}
System.out.println(s);
}
}