Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

reverse negative number

Number -- Reverse negative number
Write a return method that can reverse negative number and return it as int
 
Solution:
public static int reverseNum(int  num) {
String str = new StringBuilder(""+num).reverse().toString();
if(num < 0) {
str = "-"+str.substring(0, str.length()-1);
}
return Integer.valueOf(str);
}
Comment

PREVIOUS NEXT
Code Example
Java :: comparacion de strings java 
Java :: implement two interfaces java 
Java :: how to replace an element in array in java 
Java :: print symbol in pyramid shape in java 
Java :: How to read and write XML files 
Java :: window in java swing 
Java :: convert Date to LocalDate via Instant 
Java :: java 8 stream option 
Java :: isEmpty java code 
Java :: Java The Throw/Throws Keyword 
Java :: Java Create an InputStream 
Java :: get imei android programmatically android 10 
Java :: loop array using stream java 
Java :: reading string after double in java 
Java :: queue.isempty java 
Java :: java equal string 
Java :: how to convert iso-8859-1 to utf-8 in java 
Java :: Fix arabic javafx 
Java :: add java 8 support to pom 
Java :: java print boolean with spaces 
Java :: sorting methods in java 
Java :: exit an if statement java 
Java :: linked list vs array list 
Java :: java class in dataweave 
Java :: model mapper to list stream 
Java :: recursion of numbers in decending order in java 
Java :: difference between maven plugin and dependency 
Java :: JFrame change outline 
Java :: java string reduce 
Java :: update in spring boot 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =