how get maximum value ?

hi i have a text file likekiml23judi78ray67now i need to find out who got the maxium marks out of that ?how do i do this using java ?any idea ?regardssuis
[224 byte] By [suisa] at [2007-11-27 2:41:25]
# 1

You already know how to read a text file from your previous post:

http://forum.java.sun.com/thread.jspa?threadID=5166171 (reply #1)

And from that same thread (reply #3), you already know how to split a line of text into different parts.

When you have split the line in two parts, convert the second part to a number. Have a look at java.lang.Integer's parseInt(...) method to convert a String to a number:

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Integer.html

Now you can keep track of the largest number.

prometheuzza at 2007-7-12 3:05:12 > top of Java-index,Java Essentials,Java Programming...
# 2
Ya, i did the program earlier as you said before. many thanks for that. But now the problem is, how to find the maximum value of the array?
suisa at 2007-7-12 3:05:13 > top of Java-index,Java Essentials,Java Programming...
# 3

> Ya, i did the program earlier as you said before. many thanks for that.

> But now the problem is, how to find the maximum value of the array?

Initialize a variable called currentMax and assign it to the first value in your text file. Now loop through the entire text file and if you encounter a number that is larger than currentMax, let that value be the new currentMax.

prometheuzza at 2007-7-12 3:05:13 > top of Java-index,Java Essentials,Java Programming...