1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

If-else statement

Discussion in 'All Other Software' started by BellRaskolnikov, Feb 3, 2013.

Thread Status:
Not open for further replies.
  1. BellRaskolnikov

    BellRaskolnikov Thread Starter

    Oct 26, 2012
    Given Problem: Given an array of ints, return true if 6 appears as either the first or last element in the array. The array will be length 1 or more.
    My Answer:
    public boolean firstLast6(int[] nums) {
    for(int i = 0; i < nums.length - 1; i++){
    if ( nums[0]== 6 || nums[nums.length - 1]== 6){
    return true;
    return false;}

    This somehow return an error and it seemingly inside the if-else loop. What am i doing wrong?
  2. Cookiegal

    Cookiegal Administrator Malware Specialist Coordinator

    Aug 27, 2003
    Sorry but we don't help with homework here. You need to do the studying and research the answer on your own if you want to learn properly.

    Closing thread.
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1088096

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice