Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-23-2008, 12:19 AM
Member
 
Join Date: May 2008
Posts: 1
Rep Power: 0
javanewbie83 is on a distinguished road
Default Passing short value as parameter
Hi every1,

i have a function that accepts short as an argument:

failedcount (short responcode){

switch(responcecode){
case 1:

case 2:

case 3:
}

}


now i have a method that calls it:

create {

failedcount(3) --- here it says can't pass an int value

}

so if i do:
short abc = 3;
and then do failedcount (abc);

Thank you..
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 05-23-2008, 02:04 AM
JT4NK3D's Avatar
Member
 
Join Date: Nov 2007
Posts: 50
Rep Power: 0
JT4NK3D is on a distinguished road
Default
are you saying if you do
short abc = 3;
failedcount(abc);
it still doesnt work?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-23-2008, 04:38 AM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 234
Rep Power: 2
Eku is on a distinguished road
Default
Try converting abc into short datatype before sending it to failedcount();
__________________
Mind only knows what lies near the heart, it alone sees the depth of the soul.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-23-2008, 05:57 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Originally Posted by JT4NK3D View Post
are you saying if you do
short abc = 3;
failedcount(abc);
it still doesnt work?
No he worried about that difference there. He can't directly pass a value, and he wants to so it. Don't like to use extra lines there.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-23-2008, 05:58 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Call the method as follows.

Code:
failedcount((short)3);
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 05-23-2008, 11:19 AM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 234
Rep Power: 2
Eku is on a distinguished road
Default
thats the convertion i was talking about. =) Thats the simpliest answer. =) Im just wandering, why use short data type where you can use a int?
__________________
Mind only knows what lies near the heart, it alone sees the depth of the soul.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 05-23-2008, 11:24 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
That's his requirement.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 05-23-2008, 12:11 PM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 234
Rep Power: 2
Eku is on a distinguished road
Default
^_^ I guess i can't argue with that. Please mark this thread [SOLVED] if we satisfied your question. =P
__________________
Mind only knows what lies near the heart, it alone sees the depth of the soul.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 05-23-2008, 12:15 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Why can't you argue about that?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 06-14-2008, 03:38 AM
Member
 
Join Date: Jun 2008
Posts: 22
Rep Power: 0
ferranb is on a distinguished road
Default
A little offtopic, but take care about forgetting to use break statements on the case conditions.

Ferran
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 06-15-2008, 07:40 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
That's depend on the implementations take place. In some cases need to have more than one case statements execute at a time.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 07-12-2008, 07:19 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 1,018
Rep Power: 3
Nicholas Jordan is on a distinguished road
Default misplaced break
Originally Posted by Eranga View Post
That's depend on the implementations take place. In some cases need to have more than one case statements execute at a time.
I wonder sometimes if the misplaced break in the 1-800 incident was someone placing a break where original code relied on simple jump-table into the switch. Sort of like (??) which can be either a tool or a tarantula.
__________________
Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 07-14-2008, 05:26 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Actually using large number of case statements is bad practice, I think. I've never comes with such a situation more that 10 cases in a single application. But I've found someones code which have 30 cases, and that's the longest I've seen so far.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 07-14-2008, 06:47 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 1,018
Rep Power: 3
Nicholas Jordan is on a distinguished road
Default yep, about thirty in a switch
Originally Posted by Eranga View Post
Actually using large number of case statements is bad practice,
In general, yes. Especially when we get code like:
Code:
failedcount(3) // here it says can't pass an int value
but in my opinion building a lib that takes a list from a file ( or ram resident Collection ) and writes to a CharArrayOutputStream (${title}) would be of utility in acheiving the ability to build large switches.
Originally Posted by Eranga View Post
I think. I've never comes with such a situation more that 10 cases in a single application. But I've found someones code which have 30 cases, and that's the longest I've seen so far.
That's about the max that I could maintain by hand, an automated tool would be needful at that point.
__________________
Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #15 (permalink)  
Old 07-15-2008, 04:41 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Originally Posted by Nicholas Jordan View Post
my opinion building a lib that takes a list from a file ( or ram resident Collection ) and writes to a CharArrayOutputStream (${title}) would be of utility in acheiving the ability to build large switches.
I agreed with you. I gave the same advice to one my friends to use large switches in one of his application. He says it's fine. Even I'm not use of it, seems to me that's the best way. Actually what I believe is working with streams in much easier, much safer.

Originally Posted by Nicholas Jordan View Post
That's about the max that I could maintain by hand, an automated tool would be needful at that point.
DO you know any such methodology I can use in such instances?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #16 (permalink)  
Old 07-15-2008, 03:51 PM
Nicholas Jordan's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Southwest
Posts: 1,018
Rep Power: 3
Nicholas Jordan is on a distinguished road
Lightbulb lets build one
Originally Posted by Eranga View Post
DO you know any such methodology I can use in such instances?
It's early AM, still not awake yet, but I know from field experience that we are gonna recursively descend on Data Definitions, Type Definitions and Goal Definitions. What we will end up with is a TreeListControl, but we could have the rh view be a list of statements and the left-pane be the switch vals ( iow case n : ) the rh display would be what goes inside {}

We would need a prototype problem domain to do inital design concepting.

Creative Commons lic. Root word of license is lice. People who make license necessary won't bother to read the license. CC has accomplished a great and remarkable thawing of The Glacial Pace of Law. ( nomeclature from their field )
__________________
Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
Bookmark Post in Technorati
Reply With Quote
  #17 (permalink)  
Old 07-16-2008, 06:27 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Thanks, I'll check it and have a try. It may be really helpful to me in my projects too.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Input parameter of Main method Java Tip Java Tips 1 07-12-2008 07:24 PM
Invalid parameter binding! How to debug PreparedStatement. rjuyal Advanced Java 1 05-08-2008 10:38 AM
why doesn't this short applet work? kim85 New To Java 1 01-20-2008 09:43 PM
arugment/parameter ravian New To Java 5 01-04-2008 10:43 AM
Short/Integer mew New To Java 3 12-06-2007 10:28 PM


All times are GMT +2. The time now is 01:16 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org