fork download
  1. import java.io.*;
  2. import java.lang.*;
  3.  
  4. class StrCmp{
  5. StrCmp(){
  6. String str1 = "AMITABH BACHCHAN";
  7. String str2 = "RAJNIKANTH";
  8. int count = 0;
  9. System.out.println(str1.length);
  10. System.out.println(str2.length);
  11. }
  12. public int cmp(){
  13. for(int i = 0 ; i < str1.length ; i++)
  14. {
  15. for(int j = 0 ; j < str2.length ; j++)
  16. {
  17. if (str1[i] == str2[j])
  18. count++;
  19. else
  20. continue;
  21. }
  22. }
  23. return count;
  24. }
  25. }
  26.  
  27. public class Main{
  28. public static void main(String[] args){
  29. StrCmp strcmp = new StrCmp();
  30. int outp = strcmp.cmp();
  31. System.out.println(outp);
  32. }
  33. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:9: cannot find symbol
symbol  : variable length
location: class java.lang.String
  System.out.println(str1.length);
                         ^
Main.java:10: cannot find symbol
symbol  : variable length
location: class java.lang.String
 System.out.println(str2.length);
                        ^
Main.java:13: cannot find symbol
symbol  : variable str1
location: class StrCmp
   for(int i = 0 ; i < str1.length ; i++)
                       ^
Main.java:15: cannot find symbol
symbol  : variable str2
location: class StrCmp
   for(int j = 0 ; j < str2.length ; j++)
                       ^
Main.java:17: cannot find symbol
symbol  : variable str1
location: class StrCmp
    if (str1[i] == str2[j])
        ^
Main.java:17: cannot find symbol
symbol  : variable str2
location: class StrCmp
    if (str1[i] == str2[j])
                   ^
Main.java:18: cannot find symbol
symbol  : variable count
location: class StrCmp
     count++;
     ^
Main.java:23: cannot find symbol
symbol  : variable count
location: class StrCmp
  return count;
         ^
8 errors
stdout
Standard output is empty