PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, July 19, 2022

[FIXED] How do I reverse a number in java

 July 19, 2022     integer, java     No comments   

Issue

Can anyone explain to me how to reverse a number start with zero in java. I trying to reverse a number 025 but output is only 52. But output should be 520 explanation much appreciated.


Solution

You are mixing types. "025" is not an integer, it's a String. In integer you simply cannot distinguish between 25, 025, 0025, 00025, ... Implement your assignment as a String operation.

public String reverseString(String s) {
    // put your code here
}

You may find very useful the Oracle tutorial on Strings here: https://docs.oracle.com/javase/tutorial/java/data/strings.html



Answered By - Honza Zidek
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,260,410

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing