Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make method like getParameter()

 
Huzefa Zohaib
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the following code
public ClassA {
public static void main(String[]args) {
ClassB a= new ClassB ();
a.inter (2,'c',4);
}
}
public ClassB {
public _________ inter (int a, char c, int b) {
int d= a*b;
int e= a;
int f= b;
char g= c;
return;
}
}
what should be the reutrn type of inter(), so that I can get the value of d,e,f,g particularly when I want or when desired.
I want some thing like getParameter() which is in the HttpServletRequest object in the servlet.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you're dealing with J2EE you'll see the 'pattern' DTO (Data Transfer Object). A DTO for your example would look something like this:

Your 'inter' method could be rewritten as follows:

and the calling code could look something like this:

kind regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic