3:42 pm - Monday November 18, 1985

Vector Example program to find maxmimum element using max()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
 *@author :CandidJava.com
 *@descriptions : This program explain the function and use of max() method
 */
import java.util.Vector;
import java.util.Collections;

class FindMaximumOfVector {
	public static void main(String[] args) {
		// creating Vector Object
		Vector v = new Vector();
		v.add(new Double("324.4324"));
		v.add(new Double("345.3532"));
		v.add(new Double("342.342"));
		v.add(new Double("357.349"));
		v.add(new Double("23.32453"));
		// max()method s used to find the maximum element from the Vector
		Object obj = Collections.max(v);
		System.out.println("Maximum Element of Java Vector is : " + obj);
	}
}

OUTPUT:

D:\CandidJava\util\Vector>javac FindMaximumOfVector.java

Note: FindMaximumOfVector.java uses unchecked or unsafe operations.

Note: Recompile with -Xlint:unchecked for details.

D:\CandidJava\util\Vector>java FindMaximumOfVector

Maximum Element of Java Vector is : 357.349

BACK

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply