0

I'm working on the twosum problem:

Given nums = [2, 7, 11, 15], target = 9,

Because nums[0] + nums[1] = 2 + 7 = 9, return [0, 1].

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);
    }
        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)
                    {
                        return new int[] {i,j};
                    }

                }
            }
            return new int[] {};
        }
}

I am receiving an error that says: Error: Could not find or load main class TwoSum.java

My file name is TwoSum.java so I'm not sure what the error means

0 Answers0