java - Returning the element number of the longest string in an array -


I am trying to get the longest way to take the string-user-input array, then its element number Return the longest string in that array I found this point at the point where I was able to return the number of characters in the longest string, but I do not believe that I will work for what I need. My problem is that when I try to understand it, I keep incompatible type errors, I still do not understand the whole data type with the string, it confuses me how I have array strings, even then array numbers Have to go back about. The main method is fine, I stuck on ??? run.

  public static zero main (string [] args) {scanner inp = new scanner (System.in); String [] responseRR = new string [4]; For (int i = 0; i  

 for  (int i = 0; i  largest) {largest = value [i]. Length (); Index = i; }} Return Index;  

Note: Start with 0 - array index is int i 0-based.

Back to your main , you can System.out.println ("Longest:" + Responsible [highest]); etc.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -