← Back to topics
Topic

[ASK] Java

R
RexCoding
can anyone tell me how to use nextInt() ? i totally dont understand even the easiest probelm.
m
msantl
The code should look like this.

import java.io.*;
import java.util.*;
public class zi
{
StreamTokenizer in;
PrintWriter out;

int nextInt() throws IOException{
in.nextToken();
return (int)in.nval;
}

void run() throws IOException{
in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
out = new PrintWriter(new OutputStreamWriter(System.out));
solve();
}

void solve()throws IOException{
int a = nextInt();
//here it is
}

public static void main(String[] args)throws IOException{
new zi().run();
}
}

R
RexCoding
where I must put integer M = ... under the int a=nextInt() ?
m
msantl
The line
int a = nextInt();
is where you enter a value into variable "a".

So if you want to have a variable by the name "M" then write
int M = nextInt();