Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

fizzArray challenge

Hi,

I am working on below challenge

http://codingbat.com/prob/p180920

Psedo code description of approach :
1. identify size of array.
2. create new empty array of above size
3. keep putting each element of array with above values until size

I wrote my code as below



public int[] fizzArray(int n) {
		  int size=n;
		  int[] ar=new int[size];
		  for(int i=0;i<n;i++){
		    ar[i]=i;
		  }
		  
		  return ar;
		}

Open in new window


public class FizzArrayEx {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println("fizzArray is-->"+fizzArray(4).toString());

	}

	
	public static int[] fizzArray(int n) {
		  int size=n;
		  int[] ar=new int[size];
		  for(int i=0;i<n;i++){
		    ar[i]=i;
		  }
		  
		  return ar;
		}

}

Open in new window

i got below output
fizzArray is-->[I@15db9742

I am not seeing any test results when i ran above code

How to improve my design, approach, code? please advise
ASKER CERTIFIED SOLUTION
Avatar of mccarl
mccarl
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial