online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Online Java Compiler. Code, Compile, Run and Debug java program online. Write your code in this editor and press "Run" button to execute it. *******************************************************************************/ import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = 4; String[] usernames = new String[4]; for(int i=0; i<n; i++){ usernames[i]=scan.next(); } List<Integer> result = countDistinctCharacters(n, usernames); // System.out.println(result); System.out.print("answer = { "); for (int i : result) { System.out.print(isPrime(i) ? "1 " : "0 "); } System.out.print("}"); } public static List<Integer> countDistinctCharacters(int n, String[] usernames) { List<Integer> result = new ArrayList<>(); for (String username : usernames) { int count = 0; for (int i = 0; i < username.length(); i += 2) { if (username.indexOf(username.charAt(i)) == i) { count++; } } result.add(count); } return result; } public static boolean isPrime(int n) { if (n <= 1) { return false; } for (int i = 2; i <= n/2; i++) { if (n % i == 0) { return false; } } return true; } }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue