Get the Max Value from an Array

Get the Max Value from an Array

Please visit my YouTube channel to watch more.

This article teaches you how to get the max value from a given Array. This is a very popular interview question as well. This is the code.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package CodeTest;

/**
 *
 * @author bhanuka
 */
public class GetMaxValueFromArray {

    public static void main(String[] args) {

        int arr[] = {100, 6, 3, 7, 87, 34, 65, 120};

        int temp = 0;

        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > temp) {
                temp = arr[i];
            }
        }

        System.out.println("Max Value is :" + temp);
    }
}

Please refer to the GIT location if you want all interview questions.
You can find more Java interview question examples from here.

24 Replies to “Get the Max Value from an Array”

  1. Wonderful blog! I found it while browsing on Yahoo News.
    Do you have any tips on how to get listed in Yahoo News?
    I’ve been trying for a while but I never seem to get there!

  2. Excellent web site. Lots of useful info here. I am sending it to a few
    friends ans additionally sharing in delicious.
    And obviously, thank you on your effort!

  3. I was suggested this web site by my cousin. I’m not sure whether this post is written by him as nobody else know such detailed about my difficulty.

    You are incredible! Thanks!

  4. Thanks for ones marvelous posting! I quite enjoyed reading
    it, you will be a great author. I will always bookmark your blog and
    will eventually come back in the foreseeable future.
    I want to encourage yourself to continue your great job, have a nice
    weekend!

  5. I know this if off topic but I’m looking into starting my own weblog and was wondering what all is required to get setup?
    I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very internet smart so I’m not 100% sure. Any
    recommendations or advice would be greatly appreciated.
    Thank you

  6. Nice replies in return of this question with solid arguments and explaining all on the topic of that.

  7. Every weekend i used to go to see this web site, because i wish for enjoyment,
    as this this website conations actually nice funny information too.

  8. Fantastic website you have here but I was curious if you knew of
    any user discussion forums that cover the same topics discussed here?
    I’d really like to be a part of group where I can get feed-back from other
    knowledgeable individuals that share the same
    interest. If you have any suggestions, please let me know.
    Thanks a lot!

  9. My brother suggested I might like this web site.
    He was entirely right. This post truly made my day.
    You cann’t imagine simply how much time I had spent for this info!
    Thanks!

  10. I absolutely love your blog.. Excellent colors & theme.
    Did you create this site yourself? Please reply back as
    I’m trying to create my own website and want to learn where you got this from
    or just what the theme is called. Cheers!

  11. really smartly written article. I will be sure to bookmark it and come back to learn extra of your helpful info.

  12. Heya i’m for the first time here. I found this board and I
    find It truly useful & it helped me out much. I hope to give something back and aid others
    like you helped me.

  13. Wow, that’s what I was searching for, what a stuff!
    existing here at this web site, thanks admin of this
    site.

  14. Have you ever considered writing an e-book or guest authoring on other websites?
    I have a blog based upon on the same information you discuss and would really like
    to have you share some stories/information. I know my
    visitors would appreciate your work. If you’re even remotely interested, feel free to
    send me an e-mail.

  15. I used to be suggested this web site by means of
    my cousin. I am now not sure whether or not this submit is written by means of
    him as no one else recognize such certain about my difficulty.
    You are incredible! Thanks!

  16. Thank you for the good writeup. It in fact was a amusement account it.
    Look advanced to far added agreeable from you! By the way, how can we communicate?

  17. I don’t know whether it’s just me or if perhaps everyone else experiencing issues with your blog.
    It looks like some of the written text within your
    content are running off the screen. Can someone else please provide feedback and let
    me know if this is happening to them too? This could be a problem with my internet browser because I’ve had this happen before.
    Thank you

  18. I and my friends were found to be reviewing the excellent guidelines on your website and suddenly I got a horrible suspicion I never thanked you for those techniques. Those women are actually as a result joyful to learn all of them and have simply been having fun with these things. Appreciate your truly being so kind and then for considering this form of marvelous subject areas most people are really wanting to know about. My very own sincere regret for not expressing appreciation to you earlier.

  19. It’s appropriate time to make some plans for the future and it’s time to be happy. I have read this post and if I could I want to suggest you some interesting things or tips. Perhaps you can write next articles referring to this article. I want to read more things about it!

  20. I am actually pleased to glance at this webpage posts which includes lots of helpful facts, thanks for providing these
    kinds of statistics.

    Keep up the good work!