Reversing a String: Java vs JavaScript vs Python

Reversing a String can be done in multiple ways, using functions, loops. Let us compare how it is done in Java, JavaScript and Python. Input: Hello, How are You? Output: ?uoY era woH ,olleH Java JavaScript Python


Dynamic String Conversion in JAVA

Input: 2B Output: 2000000000 Code : import java.math.BigDecimal; import java.util.Scanner; public class DyanamicConversion { public static void main(String args[]){ //Scanner scan = new Scanner(; String a ="2M"; String[][] conversion = {{"K","1000"},{"M","1000000"},{"B","1000000000"}}; for(int i=0;i<conversion.length;i++){ if(a.endsWith(conversion[i][0])){ BigDecimal temp = new BigDecimal(a.substring(0, a.indexOf(conversion[i][0]))); temp.multiply(new BigDecimal(conversion[i][1])); a = temp.toBigInteger().toString(); System.out.println(a); break; } } } }

Sending HTTP GET Request to a REST API in JAVA

HTTP/HTTPS Get/Post request /response using JAVA below. For detailed visit here: Code: import; import; import; import; import; public class HttpURLConnection { public static void main(String[] args) throws IOException { String response = httpGet(""); } public static String httpGet(String urlStr) throws IOException { URL obj = new URL(urlStr); HttpsURLConnection con … Continue reading Sending HTTP GET Request to a REST API in JAVA