Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Ordinal numbers

807600Nov 15 2007 — edited Nov 15 2007
I am trying to code this:

The int t contains an integer between 1 and 50 (inclusive). Write code that outputs the number in words and stores the result in the String inwords. For example, if t is 35 then inwords should contain "thirty five".

int t = 35; 
    String inwords; 

inwords = Integer.toString(t);
if (inwords.substring(0, 1) == "3")
 inwords.substring(0, 1) = "thirty";
else
  ;
This is not my whole code, I was just seeing if it can work. It didn't though; it brought up an error:
TC1.java:22: unexpected type 
required: variable 
found   : value 
     inwords.substring(0, 1) = "thirty"; 
                      ^
Any suggestions?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 13 2007
Added on Nov 15 2007
7 comments
468 views