Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Tutorial about List Interface. Question

 
Nick Widelec
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Do you know what the "val == null" flow control line mean? It is not related to the iteration of the list, what kind of value is "E val" suppose to be?
Studying for the OCP that's why i need to know all these details.

Thanks in advance.
The following bit of code has been taken from http://docs.oracle.com/javase/tutorial/collections/interfaces/list.html
The line of code I do not get, is the one commented out just to highlight the line within the code.
 
Winston Gutkowski
Bartender
Pie
Posts: 10527
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nick Widelec wrote:Do you know what the "val == null" flow control line mean? It is not related to the iteration of the list, what kind of value is "E val" suppose to be?

Well, in the particular case you show, it's trying to find the element to replace. There's nothing in the rules that says a List can't contain null elements, and using equals() to check whether an object equals null doesn't make sense, because, in order to call the method, the object can't be null (and besides, you'll get a NullPointerException).

HIH

Winston
 
Mansukhdeep Thind
Ranch Hand
Posts: 1158
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch.

Do you know what the "val == null" flow control line mean? It is not related to the iteration of the list, what kind of value is "E val" suppose to be?


I believe you are new to Java language? Is that correct?
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nick Widelec wrote:what kind of value is "E val" suppose to be?


http://docs.oracle.com/javase/tutorial/java/generics/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic