I am getting Exception please check my program?

java

(Saurabh Purandare) #1

import java.util.;
import java.io.
;
import java.lang.*;

public class Tester {
public static void main(String a[])
{

    String s;

    int len;
  Scanner sc=new Scanner(System.in);

     s=sc.nextLine();

   StringBuffer sb=new StringBuffer(s);

   int i= 1;
   
   len= sb.length();

   len=len-1;

  while(i<=len)
 {
sb.deleteCharAt(i);

  i=i+2; 

}
System.out.println(sb);

}

}


(Yassine) #2

Can you share the exception details itself… and some stack trace…


#3

There is no error except in these lines:

     import java.util.*;
     import java.io.*;

(Yassine) #4

Yes, but what’s the error can you share the error you see? screenshots…etc


#5

It is just a syntax error. It is necessary for the statement to be like

    import java.util.*;

Unlike

    import java.util.;

Similarly for the other line.