Code:
import java.util.*;
import java.lang.*;
class sub
{
public static void main(String[] args)
{
String a = "1";
String b = "2";
String c = "3";
String d = "4";
String e = "5";
String f = "6";
String g = "7";
Scanner sa1 = new Scanner(System.in);
System.out.println("1) Encrypt");
System.out.println("2) Encrypt");
System.out.print("What do you want to do?: ");
int ia1 = sa1.nextInt();
if (ia1 == 1)
{
Scanner sa2 = new Scanner(System.in);
System.out.print("What do you want to encrypt?: ");
String ia2 = sa2.next();
int ia2len = ia2.length();
int cero = -1;
for (int loop = 0; loop < ia2len; loop++)
{
int cero1 = cero + 1;
int cero2 = cero + 2;
if (ia2.substring(cero1,cero2) == "a")
System.out.print(a);
else if (ia2.substring(cero1,cero2) == "b")
System.out.print(b);
else if (ia2.substring(cero1,cero2) == "c")
System.out.print(c);
else if (ia2.substring(cero1,cero2) == "d")
System.out.print(d);
else if (ia2.substring(cero1,cero2) == "e")
System.out.print(e);
else if (ia2.substring(cero1,cero2) == "f")
System.out.print(f);
else
System.out.print("no");
System.out.println();
}
}
}
}
If I input 1, then I input a, it outputs "no"
I want it to output "1"
Does anyone see what is wrong?