Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 26th, 2007, 06:19 AM
faizalkc faizalkc is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 2 faizalkc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 33 m 25 sec
Reputation Power: 0
Get method

Hi,

I am having a simple problem. Whe does my get mthod dosent work in my JSP. eg.

in jsp -->
<input name='checklist'>

in javabean -->

public String getChecklist() {
return checklist;
}


But it's empty --> System.out.println(getChecklist());

Reply With Quote
  #2  
Old March 26th, 2007, 09:55 PM
faizalkc faizalkc is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 2 faizalkc User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 33 m 25 sec
Reputation Power: 0
I got help from my friend a software engineer.

It was my mistake. In java the first letter of get/set method must be the opposite case eg variable firstname --> getFirstname. and the other letter must be the same.

TQ

Reply With Quote
  #3  
Old March 27th, 2007, 02:05 AM
daniel_g daniel_g is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 60 daniel_g User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 3 m 50 sec
Reputation Power: 3
hmm, to my understanding, that shouldn't matter at all, for instance, I could name the getFirstName() method as aaaaa() method. The problem would be trying to remember the name given to the method.

As an example, take a look at this code:
Code:
    public class TestGetSetMethod{
      String myString; //Creates a new String
       
       public TestGetSetMethod(String temp){
         GOOGLEset(temp + " Hotel"); //sets
         System.out.println(GOOGLEget()); // gets
      }
       
       public void GOOGLEset(String s){
         myString = s;
      }
      
       public String GOOGLEget(){
         return myString;
      }

       public static void main(String[] args){
         TestGetSetMethod t = new TestGetSetMethod("Paradise");
      }
   }

/*
 * Output: Paradise Hotel
 */

I named the get method GOOGLEget() and the set method GOOGLEset(), as you can see is hard to figure out that the get and set methods are related to myString, yet the code still works.
Ideally I would have named the get method as getMyString, and the set method as setMyString.

However, it's important to note that java is case sensitive, so if you name a method aAaA(), you have to call it by writting exactly aAaA(). I think your problem was because of that.

Last edited by daniel_g : March 27th, 2007 at 02:15 AM.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Get method


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT