Convert decimal number to binary – (java api, iterative & recursive)

Given a decimal number (base 10), convert decimal number to binary number (base 2) using java. We will discuss various methods to convert decimal number to binary. Convert decimal to binary using Integer class Integer.toBinaryString Integer.toString Iterative program to convert decimal number to binary number. Recursive method to convert decimal number to binary number. Methods… Read More »

Convert hexadecimal to decimal – java api, iterative & recursive

Given a hexadecimal number, convert hexadecimal number to decimal number using java. We will discuss various methods to convert hexadecimal number to decimal. Convert hexadecimal to decimal using Integer class Integer.parseInt Iterative program to convert hexadecimal number to decimal. Recursive program to convert hexadecimal number to decimal. Methods – Convert hexadecimal number to integer in… Read More »

Convert decimal to hexadecimal – java api, iterative & recursive

Given a decimal number (base 10), convert decimal to hexadecimal number (base 16) using java. We will discuss various methods to convert decimal number to hexadecimal number. Convert decimal to hexadecimal using Integer class Integer.toHexString Integer.toString Iterative program to convert decimal number to hexadecimal number. Recursive method to convert decimal number to hexadecimal number. Methods –… Read More »

Find LCM of two numbers using GCD in java (example)

LCM (Least common multiple) of two integers is the least positive integer that is divisible by both a and b. e.g  lcm(10,15) = 30 or lcm(12,18) = 36. LCM is also referred as  lowest common multiple or smallest common multiple. LCM can be calculated by calculating the GCD (greatest common divisor) of two positive integer. Example:… Read More »

Reverse each word of a string using StringBuilder in java (example)

Given a string in java, reverse each word of string using StringBuilder in java. Let us look into couple of examples to understand problem statement. Example 1: String inputString = “live star war” reverse(inputString) should be “evil rats raw” Example 2: String inputString = “live desserts” reverse(inputString) should be “evil stressed” Algorithm: reverse each word… Read More »

Reverse string word by word in java (stack/ stringbuilder /example)

Given a string in java, reverse the string word by word. Let us look into couple of examples to understand problem statement. Example 1: String inputString = “Girl Proposes Boy” reverse(inputString) should be “Boy Proposes Girl” Example 2: String inputString = “Hell To Heaven” reverse(inputString) should be “Heaven To Hell” 1. Algorithm: Reverse string word… Read More »

Page 10 of 43« First...89101112...203040...Last »