Java > Array-1 > makePi (CodingBat Solution)

Problem:

Return an int array length 3 containing the first 3 digits of pi, {3, 1, 4}.

makePi() → {3, 1, 4}


Solution:

public int[] makePi() {
  int[] myArray = new int[] {3,1,4};
  return myArray;
}


3 comments :

  1. public int[] makePi() {
    return new int[]{3, 1, 4};
    }

    ReplyDelete
  2. public int[] makePi() {
    int [] makePi = new int[] {3,1,4};
    return makePi;
    }

    ReplyDelete
  3. public int[] makePi() {

    int[] myTestArray = {3, 1, 4};

    return myTestArray;

    }

    ReplyDelete

Follow Me

If you like our content, feel free to follow me to stay updated.

Subscribe

Enter your email address:

We hate spam as much as you do.

Upload Material

Got an exam, project, tutorial video, exercise, solutions, unsolved problem, question, solution manual? We are open to any coding material. Why not upload?

Upload

Copyright © 2012 - 2014 Java Problems  --  About  --  Attribution  --  Privacy Policy  --  Terms of Use  --  Contact