Pues grave man, necesitas al menos la main; pero el codigo es simple pillalo:
import java.io.*;
public class Compare
{
static String s;
static int n1,n2;
public static void main(String args[])
{
try
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
System.out.println("Ingrese N1 = ");
s = br.readLine();
n1 = Integer.valueOf(s).intValue();
System.out.println("Ingrese N2 = ");
s = br.readLine();
n2 = Integer.valueOf(s).intValue();
if(n1 == n2)
System.out.println("Numeros Iguales");
else if(n1 > n2)
System.out.println(n1+" Mayor que "+n2);
else
System.out.println(n1+" Menor que "+n2);
}
catch(java.io.IOException ioex){}
}
}
esto compara 2 numeros y dice su relacion.
Si lo que quieres es un generador de numeros prueba con esto.
import java.io.*;
public class Generar
{
static String s;
static int n1,n2;
public static void main(String args[])
{
try
{
Double w,x;
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
System.out.println("Ingrese N1 = ");
s = br.readLine();
n1 = Integer.valueOf(s).intValue();
System.out.println("Ingrese Funcion 1-Mayor 2-Menor 3-Igual F= ");
s = br.readLine();
n2 = Integer.valueOf(s).intValue();
if(n2 == 1)
{
w = Math.random()*50;
x = (Double)(n1+w);
System.out.println(x);
}
else if(n2 == 2)
{
w = Math.random()*50;
x = (Double)(n1-w);
System.out.println(x);
}
else if(n2 == 3)
{
x = (Double)(n1+0.0);
System.out.println(x);
}
}
catch(java.io.IOException ioex){}
}
}
Esto genera un numero aleatorio mayor, menor o "igual" al ingresado.
Espero te sirva bro.