tag:blogger.com,1999:blog-2964959029992147971.post7764944568836640075..comments2024-02-12T20:14:00.868+05:30Comments on InstanceOfJava: Find second highest number in an integer Arraysaideshhttp://www.blogger.com/profile/03671387577197113199noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-2964959029992147971.post-8263339416929259422017-04-28T07:23:01.615+05:302017-04-28T07:23:01.615+05:30int max =0;
int secmax = 0;
for(i...int max =0;<br /> int secmax = 0;<br /><br /> for(int i : arr) {<br /> if(i > max) {<br /> secmax = max;<br /> max = i;<br /> }<br /> else if(i > secmax && i != max) {<br /> secmax = i;<br /> }<br /> }<br /><br /> int[] res = {max, secmax};<br /> return res;Anonymoushttps://www.blogger.com/profile/05710766046804394003noreply@blogger.comtag:blogger.com,1999:blog-2964959029992147971.post-89962594574797902622017-04-16T10:44:30.376+05:302017-04-16T10:44:30.376+05:30//add the pair of array and find highest and secon...//add the pair of array and find highest and second_higest number;<br />package com.ad;<br />public class ArrayAdd {<br /> int hig,sec_hig, k, n,m=0;<br /> void add() {<br /> int a[]= {4,6,8,9,2,6};//add {4+6=10,6+8=14...2+6=8} i.e{10,14,17,11,8} and find highest,Second_hig number;<br /> for(int i=0;i<a.length-1;i++) {<br /> m++;<br /> k=a[n]+a[m];<br /> // System.out.println(k);<br /> if(hig < k){<br /> sec_hig = hig; <br /> hig =k;<br /> } else if(sec_hig < k){<br /> sec_hig = k;<br /> }<br /> n++;<br /> }<br /> System.out.println("highest="+hig);<br /> System.out.println("Second_hig="+sec_hig);<br /> }<br /> public static void main(String[] args){<br /> ArrayAdd aa=new ArrayAdd();<br /> aa.add();<br /> }<br />}<br /><br /><br />Anonymoushttps://www.blogger.com/profile/03977007613557783516noreply@blogger.comtag:blogger.com,1999:blog-2964959029992147971.post-24917685555981362612016-07-19T01:30:02.770+05:302016-07-19T01:30:02.770+05:30import java.io.*;
class Secondhigh
{
public static...import java.io.*;<br />class Secondhigh<br />{<br />public static void main(String args[])throws IOException<br />{<br />BufferedReader br=new BufferedReader(new InputStreamReader(System.in));<br />int n;<br />System.out.println("enter size");<br />n=Integer.parseInt(br.readLine());<br />System.out.println("enter array");<br />int[] a;<br />a=new int[n];<br />for(int i=0;ia[j+1])<br />{<br /> temp=a[j];<br /> a[j]=a[j+1];<br /> a[j+1]=temp;<br />}<br />for(int i=0;i<n;i++)<br />System.out.print(a[i]);<br />System.out.println();<br />System.out.println(a[n-2]);<br />}<br />}Anonymoushttps://www.blogger.com/profile/16627544512404002416noreply@blogger.com