SuppressWarnings (“unchecked”) in Java

0 votes

Can someone explain the purpose of @SuppressWarnings("unchecked") in Java?

Sep 4, 2018 in Java by 93.lynn
• 1,560 points
65 views

1 answer to this question.

0 votes

@SuppressWarnings("unchecked") is used when Java generics just don't let you do what you want to, and thus, you need to explicitly specify to the compiler that whatever you are doing is legal and can be executed at the time of execution. In other words, it basically, tells a programmer that a cast may cause a program to throw an exception somewhere else. Suppressing the warning with @SuppressWarnings("unchecked") tells the compiler that the programmer believes the code to be safe and won't cause unexpected exceptions.

answered Sep 4, 2018 by anto.trigg4
• 3,420 points

Related Questions In Java

+1 vote
3 answers

What is the syntax to declare and initialize an array in java?

You can use this method: String[] strs = ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,190 points
258 views
0 votes
2 answers

How can I convert a String variable to a primitive int in Java

 Here are two ways illustrating this: Integer x ...READ MORE

answered 1 day ago in Java by Sirajul
• 18,370 points
111 views
0 votes
5 answers

How to compare Strings in Java?

String fooString1 = new String("foo"); String fooString2 = ...READ MORE

answered Jul 12, 2018 in Java by Daisy
• 8,040 points
105 views
+1 vote
2 answers

How to generate random integers within specific range in Java?

You can achieve that concisely in Java: Random ...READ MORE

answered Jul 25, 2018 in Java by samarth295
• 2,190 points
43 views
0 votes
1 answer
0 votes
1 answer

@Component vs @Repository vs @Service in Spring Framework

As you might be knowing, all these ...READ MORE

answered May 29, 2018 in Java by geek.erkami
• 2,320 points
692 views
+5 votes
3 answers

How to execute a python file with few arguments in java?

You can use Java Runtime.exec() to run python script, ...READ MORE

answered Mar 27, 2018 in Java by DragonLord999
• 8,380 points

edited Nov 6, 2018 by Omkar 7,168 views
0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,050 points
1,813 views
0 votes
1 answer

Retrieve all the implementations of an interface in Java

Hi...I think you can achieve this by ...READ MORE

answered Jul 23, 2018 in Java by anto.trigg4
• 3,420 points
372 views
0 votes
1 answer

Unescaping HTML character entities in Java

I guess you can use this function: StringEscapeUtils.unescapeHt ...READ MORE

answered Sep 24, 2018 in Java by anto.trigg4
• 3,420 points
19 views