9jabaze - Entertainment | Webmaster | Browsing Tricks | Games/Apps Hub
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Latest topics
» Superlative Сasual Dating - Verified Ladies
Meaning Of <?> in java EmptyWed Mar 06, 2024 11:12 pm by Litifyed

» Wapkiz 2020 Code: wapkiz register page responsive design Code
Meaning Of <?> in java EmptyThu Aug 13, 2020 5:15 pm by Hasty06

» 2020Bbnaija : Why I Can’t Be In A Relationship With Ozo – Nengi
Meaning Of <?> in java EmptyMon Jul 27, 2020 9:44 pm by Adminkunlex

» Can You Have S*x On Your First Date? Check Out What Actress, Debbie Shokoya Has To Say About This
Meaning Of <?> in java EmptyMon Jul 27, 2020 6:44 am by Adminkunlex

» Nigerian Singer, Seunfunmi Stephen, Recounts How Her Husband Was Killed By Stray Bullet
Meaning Of <?> in java EmptyMon Jul 27, 2020 6:41 am by Adminkunlex

» Olakunle Churchill Shares Photo Of Himself And Actress Rosy Meurer As He Writes On The Importance Of Loyalty
Meaning Of <?> in java EmptyMon Jul 27, 2020 6:39 am by Adminkunlex

» Ubi Franklin Reveals What Happened To Him When He Visited A Hospital Amid COVID-19 Pandemic
Meaning Of <?> in java EmptyMon Jul 27, 2020 6:37 am by Adminkunlex

» Vardy Wins Premier League Golden Boot, Beats Ings, Aubameyang & Sterling
Meaning Of <?> in java EmptyMon Jul 27, 2020 5:07 am by Adminkunlex

» The Right Way To Preach About Hell - Milton Goh
Meaning Of <?> in java EmptyMon Jul 27, 2020 5:03 am by Adminkunlex

» “Surgery For What?” – Regina Daniels Shows Off Hot Body After Childbirth (Video)
Meaning Of <?> in java EmptySun Jul 26, 2020 9:12 pm by Adminkunlex

» I Got Pregnant As A Virgin At 23 – Wathoni
Meaning Of <?> in java EmptySun Jul 26, 2020 8:24 pm by Adminkunlex

» #Bbnaija2020: Wathoni Kisses Kiddwaya During BBNaija Truth Or Dare Game
Meaning Of <?> in java EmptySun Jul 26, 2020 8:20 pm by Adminkunlex

» Bbnaija: Kiddywaya Gropes Erica’s Breast While Dancing And She Reacts
Meaning Of <?> in java EmptySun Jul 26, 2020 8:17 pm by Adminkunlex

» “I Hope To Collaborate With Rihanna & Drake Soon” – Rema
Meaning Of <?> in java EmptySun Jul 26, 2020 11:54 am by Adminkunlex

» “Girls That Give Threesome With Their Friend Have A Special Place In Heaven” – Naira Marley
Meaning Of <?> in java EmptySun Jul 26, 2020 11:50 am by Adminkunlex

» “To Be A Boss, You Must Be A Servant” – Frodd Recounts On His Humble Beginnings
Meaning Of <?> in java EmptySun Jul 26, 2020 11:48 am by Adminkunlex

» “Stop Pressuring Us With Your Beauty”, Actress Queen Nwokoye Begs Ini Edo
Meaning Of <?> in java EmptySun Jul 26, 2020 11:46 am by Adminkunlex

» You Look Like A Weed Smoker – Lady Fires Adekunle Gold Over New Look
Meaning Of <?> in java EmptySun Jul 26, 2020 11:43 am by Adminkunlex

» Davido Turns Chef, Spotted Cooking Probably For Chioma And His Crew
Meaning Of <?> in java EmptySun Jul 26, 2020 11:40 am by Adminkunlex

» Kanye West Apologizes To Kim Kardashian For Public Rants On Their Marriage
Meaning Of <?> in java EmptySun Jul 26, 2020 11:38 am by Adminkunlex

The most tagged keywords



Meaning Of <?> in java

Go down

Meaning Of <?> in java Empty Meaning Of <?> in java

Post by Adminkunlex Tue Mar 10, 2020 7:55 am

It's a wildcard. <?> is the same as <? extends Object>
- any type.
The way wildcards are usually used is <? extends Foo> (any class that extends Foo) or <? super Foo>
(any class that is a supertype of Foo)
Here is an example of usage of <?>:
Consider the following method, printList:
public static void printList(List<Object> list) {
for (Object elem : list)
System.out.println(elem + " ");
System.out.println();
}
The goal of printList is to print a list of any type, but it
fails to achieve that goal — it prints only a list of
Object instances; it cannot print List<Integer>,
List<String>, List<Double>, and so on, because they
are not subtypes of List<Object>. To write a generic
printList method, use List<?>:
public static void printList(List<?> list) {
for (Object elem: list)
System.out.print(elem + " ");
System.out.println();
}
Because for any concrete type A, List<A> is a subtype
of List<?>, you can use printList to print a list of any
type:
List<Integer> li = Arrays.asList(1, 2, 3);
List<String> ls = Arrays.asList("one", "two",
"three");
printList(li);
printList(ls);

SOURCE

Adminkunlex
Admin

Posts : 1521
Points : 4576
Reputation : 0
Join date : 2019-06-08
Age : 24
Location : Osun State, Nigeria

https://9jabaze.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum