Results 1 to 17 of 17
Thread: Passing short value as parameter
- 05-22-2008, 11:19 PM #1
Member
- Join Date
- May 2008
- Posts
- 1
- Rep Power
- 0
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, 01:04 AM #2
are you saying if you do
short abc = 3;
failedcount(abc);
it still doesnt work?
- 05-23-2008, 03:38 AM #3
Senior Member
- Join Date
- May 2008
- Location
- Makati, Philippines
- Posts
- 234
- Rep Power
- 6
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, 04:57 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 05-23-2008, 04:58 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Call the method as follows.
Java Code:failedcount((short)3);
- 05-23-2008, 10:19 AM #6
Senior Member
- Join Date
- May 2008
- Location
- Makati, Philippines
- Posts
- 234
- Rep Power
- 6
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, 10:24 AM #7
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 05-23-2008, 11:11 AM #8
Senior Member
- Join Date
- May 2008
- Location
- Makati, Philippines
- Posts
- 234
- Rep Power
- 6
^_^ 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, 11:15 AM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Why can't you argue about that?
- 06-14-2008, 02:38 AM #10
Member
- Join Date
- Jun 2008
- Posts
- 22
- Rep Power
- 0
A little offtopic, but take care about forgetting to use break statements on the case conditions.
Ferran
- 06-15-2008, 06:40 AM #11
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
That's depend on the implementations take place. In some cases need to have more than one case statements execute at a time.
- 07-12-2008, 06:19 PM #12
misplaced break
Introduction to Programming Using Java.
Cybercartography: A new theoretical construct proposed by D.R. Fraser Taylor
- 07-14-2008, 04:26 AM #13
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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.
- 07-14-2008, 05:47 PM #14
yep, about thirty in a switch
In general, yes. Especially when we get code like:
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.Java Code:failedcount(3) // here it says can't pass an int value
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
- 07-15-2008, 03:41 AM #15
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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.
DO you know any such methodology I can use in such instances?
- 07-15-2008, 02:51 PM #16
lets build one
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
- 07-16-2008, 05:27 AM #17
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Thanks, I'll check it and have a try. It may be really helpful to me in my projects too.
Similar Threads
-
Input parameter of Main method
By Java Tip in forum Java TipReplies: 1Last Post: 07-12-2008, 06:24 PM -
Invalid parameter binding! How to debug PreparedStatement.
By rjuyal in forum Advanced JavaReplies: 1Last Post: 05-08-2008, 09:38 AM -
why doesn't this short applet work?
By kim85 in forum New To JavaReplies: 1Last Post: 01-20-2008, 08:43 PM -
arugment/parameter
By ravian in forum New To JavaReplies: 5Last Post: 01-04-2008, 09:43 AM -
Short/Integer
By mew in forum New To JavaReplies: 3Last Post: 12-06-2007, 09:28 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks