Given integer as a input, why string is working?

in question given take integer as input but i am taking string as a input , how can i store int in to String ??

Use Integer.toString(x)

this is not my doubt, i mean input format in question is take a input as a integer up to 10^18 range, but if i am entering a integer , i can’t store in int but it is working when i am taking input in string , so how input int are store in String without any function;
String str=sc.next(); it will accept only String ryt?? so why it is accepting integer, or why in question written take integer.???

just use in.nextLong() and take input in long variable. No issues of taking in strings.

its not my query , why integer is accepting in String ??I write String Method (next()) , but i am entering integer ,

that doesn’t matter. If you use, next() method, anything in the line is accepted as string