How to return two values from one method ??
for example i've made the following program.
import java.io.*;
class vowel{
public static void main (String args[])throws IOException{
String sentence;
InputStreamReader isr = new InputStreamReader (System.in);
BufferedReader br = new BufferedReader (isr);
sentence = br.readLine();
System.out.print (vowels(sentence));
}
static char vowels (String default1){
char ch;
int vowels_position [] = {0,0,0,0,0};
char vowels_value [] = {'a','e','i','o','u'};
for (int i=0; i<default1.length(); i++){
ch=default1.charAt(i);
switch (ch) {
case 'a': case 'A':{vowels_position[0]++;break;}
case 'e': case 'E':{vowels_position[1]++;break;}
case 'i': case 'I':{vowels_position[2]++;break;}
case 'o': case 'O':{vowels_position[3]++;break;}
case 'u': case 'U':{vowels_position[4]++;break;}
}
}
int count=0;
for (int k=0; k<vowels_position.length; k++)
if (vowels_position[k]>vowels_position[count])
count=k;
return (vowels_value[count]);
}
}
this program counts every vowel in a string and then return the vowel which appeared mostly, i want my program not only return the vowel that appeared most time but also return count of that vowel.
i want to return vowels_value[count] & vowels_position[count]