Q:

How to compare String with Int

public static void main(String[] args){     
    String buf;

    buf = JOptionPane.showInputDialog("1, 2 or 3");

    if (buf == 1) {
        Begin2();}//if a
    if (buf == 2) {
        Main.Begin6();}//if b
    if (buf == 3) {
        Main.Begin7();}//if b
}

I have this code, but if cant invoke any of Begin methods...

A:

Either
if("1".equals(buf)) {
    Begin2();
} else if ("2".equals(buf)) {
    Main.Begin6();
} else if ("3".equals(buf)) {
    Main.Begin7();
}

or
switch(buf) {
    case "1": Begin2(); break;
    case "2": Main.Begin6(); break;
    case "3": Main.Begin7(); break;
    default: break;
}

would do the job.

