fork(2) download
  1. class Example
  2. {
  3. public static void main (String[] args) throws java.lang.Exception
  4. {
  5. String[] name = { "a" , "b" , "c" , "d"};
  6. int n;
  7. n = 4 % name.length;
  8. System.out.println(" 4 % 4 is " + n + ": " + name[n]);
  9. n = 7 % name.length;
  10. System.out.println(" 7 % 4 is " + n + ": " + name[n]);
  11. n = 50 % name.length;
  12. System.out.println("50 % 4 is " + n + ": " + name[n]);
  13. }
  14. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
 4 % 4 is 0: a
 7 % 4 is 3: d
50 % 4 is 2: c