how to add more methods to class methods

Hello all

I don抰 know how exactly explain my problem but I will try .

I have base class that has some methods that I use on the jsp page.

my base class looks like this :

class base{

publicstatic String getName(){

String myName =new String("miki");

return myName;

}

publicstaticint getAge(){

int myAge =new Int(30);

return myAge;

}

}

now I will like this methods to have more methods for example toBoolean()

so if I will do :

<%

base.getAge().toBoolean();

or

base.getAge().toBoolean();

%>

it willreturn metrue orfalseif age is less then 0 sofalse

andif the name string len is 0 also flase

and other wisetrue ;

how can I implementthis functions on my methods?

hope I made my self clear

thanks

[1713 byte] By [Meirya] at [2007-10-3 4:11:25]
# 1

Think about what is actually happening with those strung calls. Using your example, what would toBoolean() be being called on. It is not being called on base, and you cannot call a method on a method, so it is not being called on getAge(). What it is being called on, is what is returned by getAge(). The only way to string calls in this manner, is when the object returned by the previous method, contains the next method. Since getAge() returns an int, you can't string anything onto it. You would have to modify getAge to return an object that you created, which, of course, would also mean to modify anything that has used getAge() up to this point to expect your new object and use it, rather than an int.

masijade.a at 2007-7-14 22:11:56 > top of Java-index,Java Essentials,New To Java...