Error is showing

When I am typing “Scanner scn = new Scanner(System.in);”, it is showing an underline under “scn”, i.e., an error. Please explain why and please give a solution.

Output is not showing. Just an underline under scn.

@saijaltripathy_e79096f8f1ec20e3 you need to import scanner before you use this. To import scanner you need to add following line just below your package name and just above where your class starts.
import java.util.Scanner;

I have already imported

@saijaltripathy_e79096f8f1ec20e3 send me your exact code and if possible please attach an image of the error.

Ok please wait a min

@saijaltripathy_e79096f8f1ec20e3 yeah

see, there is a yellow underline under scn

@saijaltripathy_e79096f8f1ec20e3 yellow line things are not errors they are warnings. This warning is coming because your haven’t closed the scanner and closing the scanner is a good practice. To remove this warning add a line after you have taken every input :
scn.close(); and you will not see any warning. Now coming to your issue that no output is showing. It is because you haven’t gave any input in the console. To do that run your program and the console will get automatically opened type your int value which you need to be stored in ‘n’ after entering the value press enter you will see the output.

But the console only is not opening. So what to do

But when I was seeing the recorded lecture of Garima Ma’am, no such warning was showing in her code.

@saijaltripathy_e79096f8f1ec20e3 in the search icon in the upper right corner. Search console and open from there.

@saijaltripathy_e79096f8f1ec20e3 because at that time eclipse didn’t gave that warning. This warning is in newer versions of eclipse.

Oh okay Sir. Please give me a few minutes so that I can check.

@saijaltripathy_e79096f8f1ec20e3 yeah sure

Yes Sir, now the console and output both are showing. Thank you so much for your help.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like

Yes sure. Kindly tell me where can I give the feedback.