Originally posted by Adam Brown:
withour examining at the code itself, is there a method that will tell me what type a variable is. For example, i want to distinguish an int from a char.
thanks in advance,
Adam
SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
Originally posted by Cheng Wei Lee:
An ugly method is to use the instanceof operator for all primitive types, if you're expecting your variable to be a primitive.
Mike Gershman
SCJP 1.4, SCWCD in process
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Originally posted by Adam Brown:
would I have to create a custom Exception class to handle whether or not that value could or could not be converted into a double?
Originally posted by Adam Brown:
I suppose what I am trying to accomplish is the throwing of an exception in my code if a primitive is of a specific type.
For example, I have a JTextField that reads a double value that will be manipulated in some sort of financial equasion. Granted, I understand that a JTextField takes a string argument and has to be parsed into a double value, but would I have to create a custom Exception class to handle whether or not that value could or could not be converted into a double?
This was a problem that was presented in class, and everyone is kind of chewing on it for the time being (including our professor).
If someone does not want to give me the answer but rather point me in the right direction I would be very grateful.
Originally posted by Adam Brown:
I apologize for both the delay in this post and the clarification needed. I suppose what I am trying to accomplish is the throwing of an exception in my code if a primitive is of a specific type.
For example, I have a JTextField that reads a double value that will be manipulated in some sort of financial equasion. Granted, I understand that a JTextField takes a string argument and has to be parsed into a double value, but would I have to create a custom Exception class to handle whether or not that value could or could not be converted into a double?
This was a problem that was presented in class, and everyone is kind of chewing on it for the time being (including our professor). It has turned into a kind of competition, actually, to see who can research and find the most elegant solution. If someone does not want to give me the answer but rather point me in the right direction I would be very grateful.
Thanks in advance,
Adam
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |