Static method
i have a small problem with a java program that i need to create. i am quite new to this language and would be grateful for your help.
the problem is that i have to create a class which has a static method which will only return vowels. then i need to create another which calls the that method and prints out the result (without instantiatiating the previous object).
[381 byte] By [
NasirKa] at [2007-10-2 14:55:27]

"only return vowels" is not very decriptive. This meets your stated requirements: class Foo {
static char vowel() {
switch(System.currentTimeMillis() % 5) {
case 0:
return 'a';
case 1:
return 'E';
case 2:
return 'i';
case 3:
return 'O';
case 4:
return 'u';
default:
assert false : "cannot get here";
}
}
class Bar {
static void callVowel() {
System.out.println(Foo.vowel());
}
}
jverda at 2007-7-13 13:37:19 >

ok thanks so much. when i say return only vowels, i mean for example, if you take a word like "hello", then it will return only the vowels.
> ok thanks so much. when i say return only vowels, i
> mean for example, if you take a word like "hello",
> then it will return only the vowels.
That's still not clear.
Is it supposed to return an array? A List? What if a vowel appears multiple times--does it appear that many times int the returned array, List, whatever?
And no, I won't do it for you. Try it. Do as much as you can until you get completely stuck, then post what you've got, along with specific questions.
When you post code, please use[code] and [/code] tags as described in [url=http://forum.java.sun.com/help.jspa?sec=formatting]Formatting tips[/url] on the message entry page. It makes it much easier to read.
jverda at 2007-7-13 13:37:19 >

ok then thanks man, i think i get it now, i will post the code soon to see what ive done is right, many thanks for your help.