Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Missing return statement

$
0
0
I'm very new to java and do not understand why I am getting this error. The program is not complete and I have tried to make it obvious where I will be adding code. The first method will be checking to make sure that the array being used contains non repeating numbers. The second one will simply print out the array. As of now I just filled the two empty methods with simple print statements as a test. Anyway, it is highlighting the brace on line #5 with as the cause of the error. I cannot see anything wrong with the code. Any advice would be appreciated.

public class DistinctCheck {
    public static boolean areDistinct(int[] a) {
        System.out.print("code1");
       // CODE GOES HERE
    }
    
    
    public static void printIntArray(int[] a) {
        System.out.print("code2");
       // CODE GOES HERE
    }
    
    public static void main(String[] args) {
        int[] a1 = {1,2,3,4,5,6,7,8,9};
        System.out.println("First array is printed below: ");
        printIntArray(a1);
        System.out.println("areDistinct for first array: " + areDistinct(a1));
        
        int[] a2 = {1,3,5,7,6,4,3,2};
        System.out.println("Second array is printed below: ");
        printIntArray(a2);
        System.out.println("areDistinct for second array: " + areDistinct(a2));
    }
}

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>