|
|
Welcome to the Java Forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
- have access to post topics
- communicate privately with other members (PM)
- not see advertisements between posts
- have the possibility to earn one of our surprises if you are an active member
- access many other special features that will be introduced later.
Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact us.
|
|

05-23-2008, 12:19 AM
|
|
Member
|
|
Join Date: May 2008
Posts: 1
|
|
|
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..
|
|

05-23-2008, 02:04 AM
|
 |
Member
|
|
Join Date: Nov 2007
Posts: 50
|
|
|
are you saying if you do
short abc = 3;
failedcount(abc);
it still doesnt work?
|
|

05-23-2008, 04:38 AM
|
|
Senior Member
|
|
Join Date: May 2008
Location: Makati, Philippines
Posts: 199
|
|
|
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.
|
|

05-23-2008, 05:57 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,486
|
|
Originally Posted by JT4NK3D
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. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

05-23-2008, 05:58 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,486
|
|
Call the method as follows.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

05-23-2008, 11:19 AM
|
|
Senior Member
|
|
Join Date: May 2008
Location: Makati, Philippines
Posts: 199
|
|
|
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.
|
|

05-23-2008, 11:24 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,486
|
|
That's his requirement. 
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

05-23-2008, 12:11 PM
|
|
Senior Member
|
|
Join Date: May 2008
Location: Makati, Philippines
Posts: 199
|
|
|
^_^ 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.
|
|

05-23-2008, 12:15 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,486
|
|
|
Why can't you argue about that?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

06-14-2008, 03:38 AM
|
|
Member
|
|
Join Date: Jun 2008
Posts: 22
|
|
|
A little offtopic, but take care about forgetting to use break statements on the case conditions.
Ferran
|
|

06-15-2008, 07:40 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,486
|
|
|
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. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-12-2008, 07:19 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Southwest
Posts: 567
|
|
|
misplaced break
Originally Posted by Eranga
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.
__________________
Please provide your feedback on our To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. .
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
|
|

07-14-2008, 05:26 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,486
|
|
|
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. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-14-2008, 06:47 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Southwest
Posts: 567
|
|
|
yep, about thirty in a switch
Originally Posted by Eranga
Actually using large number of case statements is bad practice,
In general, yes. Especially when we get code like:
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
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.
__________________
Please provide your feedback on our To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. .
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
|
|

07-15-2008, 04:41 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,486
|
|
Originally Posted by Nicholas Jordan
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
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. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

07-15-2008, 03:51 PM
|
 |
Senior Member
|
|
Join Date: Jun 2008
Location: Southwest
Posts: 567
|
|
|
lets build one
Originally Posted by Eranga
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 )
__________________
Please provide your feedback on our To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. .
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
|
|

07-16-2008, 06:27 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,486
|
|
|
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. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|