aspose file tools
The moose likes Java in General and the fly likes veriables in Java Bean Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "veriables in Java Bean" Watch "veriables in Java Bean" New topic
Author

veriables in Java Bean

Vilas Lawande
Ranch Hand

Joined: Nov 07, 2006
Posts: 127
Writing variables is like in Java Bean like

1. private String password;
2. private String password = null;
3. private String password = "";

Which will be better programming approach and why?
Please elaborate.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3268

Well, it all depends on what you want your variables to be initialised to! There is no 'best answer' in this case, although I suspect a lot of people by default (and IDEs) would produce private String password; (which is effectively the same as private String password = null;).


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Vilas Lawande
Ranch Hand

Joined: Nov 07, 2006
Posts: 127
Thank a lot.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3268

You're welcome
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: veriables in Java Bean
 
Similar Threads
Hibernate problem
password in struts
File transfering from client machine to Server through FTP.
How mapping of controls in jsp file and attributes in javabean (FormBean) is done ?
Keeping current logged user.