compile error java

/* package codechef; // don’t place package name! */

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

/* Name of the class has to be “Main” only if the class is public. */
class codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner in=new Scanner (System.in);
System.out.println(“Enter the ocde”);
int n=in.nextInt();
if(n==0)
System.out.println(“HI”);
else
System.out.println(“HELLO”);
}
}

You don’t need to throw an exception however if you want to just change the “throws java.lang.Exception” to “throws IOException”

Just do like

//just import the package you need in your case you just need the scanner
package

 import java.util.Scanner; 
 public class Main
   {

  public static void main(String[] args)
  {

     Scanner in=new Scanner(System.in);

     System.out.println("Enter the ocde");
     int n=in.nextInt();
    if(n==0) 
       System.out.println("HI"); 
    else 
      System.out.println("HELLO"); 
      }
   }

it will be import java.io.*; and import java.util.*:
and thats all you need!

asterik is not being printed asterik will be there after io. and util.

Fixed the asterik

1 Like

thnks bro!