Check Two Numbers for Equality in Java

karthikeya Boyini
Updated on 26-Jun-2020 10:44:37

12K+ Views

To check two numbers for equality in Java, we can use the Equals() method as well as the == operator.Firstly, let us set Integers.Integer val1 = new Integer(5); Integer val2 = new Integer(5);Now, to check whether they are equal or not, let us use the == operator.(val1 == val2)Let us now see the complete example.Example Live Demopublic class Demo {    public static void main( String args[] ) {       Integer val1 = new Integer(5);       Integer val2 = new Integer(5);       Integer val3 = new Integer(10);       System.out.println("Integer 1 = "+val1);   ... Read More

Best Place for Engineering Jobs: India or Abroad

Shanmukh Pasumarthy
Updated on 26-Jun-2020 10:43:59

153 Views

When it comes to Engineering jobs in India, thousands of Government vacancies and lakhs of jobs in the Indian private sector come up every month. There is no dearth of jobs for engineers in India. But if you are interested to go abroad, there are many places around the world to go.These days many students are preferring to look for some good jobs in India itself. Due to Visa hassles and insecurity, many youngsters are preferring to settle down in their homeland. That is a welcome trend.

8085 Program to Multiply Two 8-Bits Numbers

George John
Updated on 26-Jun-2020 10:42:57

1K+ Views

In this program, we will see how to multiply two 8-bit numbers using 8085 microprocessor.Problem StatementWrite 8085 Assembly language program to multiply two 8-bit numbers stored in a memory location and store the 16-bit results into the memory.DiscussionThe 8085 has no multiplication operation. To get the result of multiplication, we should use the repetitive addition method. After multiplying two8-bit numbers it may generate 1-byte or 2-byte numbers, so we are using two registers to hold the result.We are saving the data at location 8000H and 8001H. The result is storing at location 8050H and 8051H.InputAddressData......8000DC8001AC......Flow DiagramProgramAddressHEX CodesLabelsMnemonicsCommentsF00021, 00, 80LXIH, 8000HLoad first ... Read More

Convert Hexadecimal Number to Decimal Number in Java

karthikeya Boyini
Updated on 26-Jun-2020 10:42:43

455 Views

Use the parseInt() method with the second parameter as 16 since it is the radix value. The parseInt() method has the following two forms.static int parseInt(String s) static int parseInt(String s, int radix)To convert hex string to decimal, use the 2nd syntax and add radix as 16, since hexadecimal radix is 16.Integer.parseInt("12", 16)Example Live Demopublic class Demo {    public static void main( String args[] ) {       // converting to decimal       System.out.println(Integer.parseInt("444", 16));    } }Output1092

Convert Octal Number to Decimal Number in Java

Samual Sam
Updated on 26-Jun-2020 10:42:10

341 Views

Use the parseInt() method with the second parameter as 8 since it is the radix value. The parseInt() method has the following two forms.static int parseInt(String s) static int parseInt(String s, int radix)To convert octal to decimal, use the 2nd syntax and add radix as 8, since octal radix is 8.Integer.parseInt("25", 8)The following is an example.Example Live Demopublic class Demo {    public static void main( String args[] ) {       // converting to decimal       System.out.println(Integer.parseInt("25", 8));    } }Output21

8085 Program to Divide Two 8-Bit Numbers

Chandu yadav
Updated on 26-Jun-2020 10:41:21

17K+ Views

In this program, we will see how to divide two 8-bit numbers using 8085 microprocessor.Problem StatementWrite 8085 Assembly language program to divide two 8-bit numbers and store the result at locations 8020H and 8021H.DiscussionThe 8085 has no division operation. To get the result of the division, we should use the repetitive subtraction method. By using this program, we will get the quotient and the remainder. 8020H will hold the quotient, and 8021H will hold the remainder.We are saving the data at location 8000H and 8001H. The result is storing at location 8050H and 8051H.InputThe Dividend: 0EHThe Divisor 04HThe Quotient will be ... Read More

Convert Decimal Integer to Hexadecimal Number in Java

Samual Sam
Updated on 26-Jun-2020 10:41:08

411 Views

Use the toHexString() method to convert decimal to hexadecimal. The method returns a string representation of the integer argument as an unsigned integer in base 16. The following characters are used as hexadecimal digits:0123456789abcdef.The following is the syntax.String toHexString(int i)It has only single parameter.i − This is an integer to be converted to a string.Example Live Demopublic class Demo {    public static void main( String args[] ) {       int dec = 45;       System.out.println("Decimal = "+dec);       // converting to hex       System.out.println(Integer.toHexString(dec));    } }OutputDecimal = 45 2d

Boolean Literals in Java

karthikeya Boyini
Updated on 26-Jun-2020 10:40:43

819 Views

The Boolean literals have two values i.e. True and False.The following is an example to display Boolean Literals.Example Live Demopublic class Demo {    public static void main(String[] args) {       System.out.println("Boolean Literals");       boolean one = true;       System.out.println(one);       one = false;       System.out.println(one);    } }OutputBoolean Literals true falseIn the above program, we have declared a boolean value and assigned the boolean literal “true”.boolean one = true;In the same way, we have added another boolean literal “false”.one = false;Both of the above values are displayed, which are the boolean literals.

Integer rotateLeft Method in Java

Samual Sam
Updated on 26-Jun-2020 10:40:18

126 Views

The Integer.rotateLeft() method returns the value obtained by rotating the two's complement binary representation of the specified int value i left by the specified number of bits. The following is the syntax.int rotateLeft(int i, int distance)Here are the parameters.i − This is the int value.distance − This is the rotation distance.Example Live Demopublic class Demo {    public static void main(String []args) {       int val = 1;       for (int i = 0; i < 4; i++) {          val = Integer.rotateLeft(val, 1);          System.out.println(val);       }    } }Output2 4 8 16

Integer Signum Method in Java

karthikeya Boyini
Updated on 26-Jun-2020 10:39:47

154 Views

The method returns the signum function of the specified int value. Let us now see the syntax.int signum(int i)Here is the parameter.i − This is the int valueThe return value is -1 if the specified value is negative, 0 if the specified value is zero and 1 if the specified value is positive.Let us now see an example.Example Live Demopublic class Demo {    public static void main(String []args) {       System.out.println("Returns = "+Integer.signum(0));       System.out.println("Returns = "+Integer.signum(-99));       System.out.println("Returns = "+Integer.signum(678));    } }OutputReturns = 0 Returns = -1 Returns = 1

Advertisements