SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Wouter Oet wrote:With "normal" Java you can't. But with reflection you can:
But then again, why would you want this?
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Joanne
Joanne Neal wrote:You could write a loop to call charAt method until you get an out of bounds exception.
Joe Ess wrote:That's the direction I was heading, but I didn't want to give it away unless this was homework. . .
might have been a little discouraging, so I thought I'd give him a nudge in a possible direction.Rob Prime wrote:You can't. Period.
Joanne
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
I agree, but when you get these sort of requirements, sometimes you have to turn to the dark side.Rob Prime wrote:Using exceptions for control flow is just bad.
Joanne
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:Ah right. I never think of these nasty ways. Using exceptions for control flow is just bad.
Life is full of choices. Sometimes you make the good ones, and sometimes you have to kill all the witnesses.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Prime wrote:It would still be the length of the original String. indexOf would return the index of the A character which is at the end of the original String. Therefore, the index of the A in the modified String is equal to the size of the original String.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Jelle Klap wrote:I know, but I still think it's cheating
![]()
Life is full of choices. Sometimes you make the good ones, and sometimes you have to kill all the witnesses.
Ivan Jozsef Balazs wrote:This "solution" not only avoids the usage of length() on strings, stringbuffers etc. but it is also very inefficient...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
luck, db
There are no new questions, but there may be new answers.
without using any built in length methods or length properties.
Interesting approach. TextLayout could give you a more accurate result.How about creating a JLabel ...
hm, the OP stated
Seems to me that would exclude bitLength()without using any built in length methods or length properties.
luck, db
There are no new questions, but there may be new answers.