File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes code problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "code problem" Watch "code problem" New topic
Author

code problem

ten doeschate
Greenhorn

Joined: Jun 22, 2013
Posts: 16
i want to reverse the output ie 5 4 3 2 1 to 1 2 3 4 5 how to do it
my code is
Mark Beardsley
Ranch Hand

Joined: Jun 07, 2013
Posts: 32
    
    1
Must admit that I would convert the value into a String and then simply use Java's String handling capabilities to reverse the order of the characters.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2175
    
  47
i want to reverse the output ie 5 4 3 2 1 to 1 2 3 4 5 how to do it

Sorry but what part are you stuck on? your code would appear to do what you want.
Ishan Pandya
Ranch Hand

Joined: Feb 06, 2012
Posts: 219

What is the output you are getting?? and what is the problem?? could you please mention that?


OCPJP
ten doeschate
Greenhorn

Joined: Jun 22, 2013
Posts: 16
getting output as 5 4 3 2 1

but i want 1 2 3 4 5

not able to reverse order from the above code
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2175
    
  47
But your seed number is 12345 so it will reverse to 54321. If you want an output of 12345 you will need to start with 54321.
Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 138

Whats wrong? The input considered is 12345 whose reverse is 54321?

Am i missing something?


Regards,
Prajakta
ten doeschate
Greenhorn

Joined: Jun 22, 2013
Posts: 16
but i want to print 1 2 3 4 5
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2175
    
  47
I've already told you what to do but if you don't understand what I said think about the problem yourself. If you have code that reverses a number ie changes 6789 to 9876 and if you want a specific output such as 12345 what number do you have to start with so when it is reversed it will be 12345.
Ishan Pandya
Ranch Hand

Joined: Feb 06, 2012
Posts: 219

why dont you just print i before the while loop..you will get your output.
@tony- i dont think he is getting you.
mykodes java
Greenhorn

Joined: Jul 06, 2013
Posts: 1
ten doeschate,

Use this code.


 
Don't get me started about those stupid light bulbs.
 
subject: code problem
 
Similar Threads
[solved]warning message:" Accessing static method numbers" #7th floor
Wrapper class Long.toString() method
Arrays...
Finding the closet element to Zero in a Array
Thread Output