• Post Reply Bookmark Topic Watch Topic
  • New Topic

PMD- Position literal first in string comparisions  RSS feed

 
Ashwin Bharadwaj
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

Can anyone help me to resolve PMD-design violation error for the below code.



I am facing error at line no 5 & 6


Thanks
Ashwin.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code. It will highlight your code and make it much easier to read. It probably will also increase the number of people helping you. You can edit your post with the button.

I think that they want this:


And you should make your LinkedList generic. Why did you choose for a LinkedList and not an ArrayList?
 
Ashwin Bharadwaj
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Wouter,

It worked for me.

Thanks for the response


Thanks
Ashwin
 
Ashwin Bharadwaj
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Wouter,


Can you please help me how to use ArrayList instead of LinkedList

Thanks
Ashwin
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply change the right hand side of line 2?
 
Ashwin Bharadwaj
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob Prime
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you really want "null"? Do you mean null instead? There is a big difference. You may actually want to test whether your entry == null.
 
Ashwin Bharadwaj
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Campbell,

Yes i want to test for entry == null.

 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or more likely, entry != null. Look at this old thread, but note I made a mistake and had to correct it. The correction will probably tell you what you want to know.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!