JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
public class Program
{
public static void main(String[] args) {
int int1=100;
int int2=1000;
long long1=100;
long long2=1000;
String string1="100";
String string2="1000";
String string3="100";
compareIntBeforeTest (int1 ,int2 );
compareInt(int1,int2);
compareLong(long1,long2);
compareString(string1,string2);
compareStringSameLength (string1 ,string3);
compareStringLength (string1 ,string2);
compareStringHashCode (string1 ,string2 );
}
public static void compareIntBeforeTest (int int1 ,int int2 ){
long startTime=System.nanoTime();
System.out.println(int1==int2);
long endTime=System.nanoTime();
System.out.println("Before test compare two int. Time: "+(endTime -startTime)+" nanoseconds");
}
public static void compareInt (int int1 ,int int2 ){
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run