Scanner input = new Scanner(System.in);
String girdi = input.nextLine();
for(int i=1; i<girdi.length(); i+=1){
if(girdi.charAt(i) == '*'){
int temp1= girdi.charAt(i-1)-'0';
int temp2= girdi.charAt(i+1)-'0';
int temp3 = temp1 * temp2;
String a = girdi.substring(i-1,i);
String b = "" + temp3;
String a2 = girdi.substring(i+1,i+2);
String b2 = girdi.substring(i , i+1);
girdi = girdi.replaceFirst(a,b);
girdi = girdi.replaceFirst(b2, "");
girdi = girdi.replaceFirst(a2, "");
}
}
I am just trying to make multiplication
when I type something like that (3*5) give me that error:
Exception in thread "main" java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
and when I am using backslah to escape :
if(s.charAt(i) == '\\*'){
I see unclosed character literal and illegal start of expression errors
what should I do?
sis"4 * 5", you've still got no regexes in the code you've shown.