After I compile my code, I see this as the output:
[I@7852e922
I'm assuming I need to use Array.toString after some searching but when I I seem to have other errors so I'm assuming I'm not putting it in the right place.
Here is my code:
public class TwoSum
{
static int[] arraynums = new int[]{2, 7, 11, 15};
static int target = 9;
public static void main(String args[])
{
//TwoSum name = new TwoSum();
//name.twoSums(arraynums, target);
System.out.println(twoSums(arraynums, target));
}
public static int[] twoSums(int[] nums, int target)
{
int sum = 0;
for (int i = 0; i < nums.length; i++)
{
for (int j = 0; j < nums.length; j++)
{
sum = nums[i] + nums[j];
if (sum == target)
{
//System.out.println(i + " " + j);
return new int[] {i,j};
}
}
}
return new int[] {};
}
}