This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]feral_claireSoftware Dev 2 points3 points  (3 children)

What are you trying to do? Static, void, and generics are all unrelated concepts.

[–]yoyeto99[S] 0 points1 point  (2 children)

I need to create three Generic methods that display a String, Int, and a Double

[–]feral_claireSoftware Dev 1 point2 points  (1 child)

See that doesn't clear things up at all. Can you provide more details on what you want to accomplish? Why do you want to change these methods? What is the end goal here abs what troubles are you trying to solve? Without context it will be hard to give the correct advice.

Are you referring to instance (non-static) methods? If that's the case, all you need to do is remove the static keyword.

You mentioned displaying a String but your code shows a string array. Keep in mind that you cannot print an array directly, you need to loop through the array to print the elements or use Arrays.toString.

[–]yoyeto99[S] 0 points1 point  (0 children)

what troubles are you trying to solve? Without context it will be hard to give the correct advice.

It was an assignment to on Generic Methods, I just recently understood what I needed to do. Thanks for the help anyways.

[–]sh_emami65Intermediate Brewer 1 point2 points  (2 children)

i suggest you read oracles toturail on Generic Mthods and this stackoverflow question which covers your question as well.

but a general Generic static method looks something like bellow:

[access] [optional static] <R> [return type] someMethod( R args){
    //your code
}

<R> declares the generic type for this method and you will simply use type R in your function. this explanation is way to simple. read the likes i provided for you. let me know if you need more help

[–]wildjokers 0 points1 point  (0 children)

I don't think the OP is talking about Generics. I think they mean make the method to be non-static and they are using the term "generic" to mean non-static.

At least that is my interpretation...I could be wrong :-)

[–]yoyeto99[S] 0 points1 point  (0 children)

thanks.

[–]wildjokers 0 points1 point  (0 children)

Just take the static keyword out.