You are on page 1of 3

Practical 15.

class stringToInteger{

public static void main(String args[]){

String str = "123";

Integer i =Integer.valueOf(str);

System.out.println("The Integer value of String is. "+i);

Output

The Integer value of String is .123

Practical 15.3

import java.lang.*;

class intwrapper{

public static void main(String args[]){

int a = Integer.parseInt("14");

int b = Integer.parseInt("16");

int c = a+b;

System.out.println("Addition of "+a+" and "+b+" is " +c);

Integer i = new Integer("30");

String str = i.toString();

System.out.println("String:"+str);

Integer obj1 = new Integer ("25");

Integer obj2 = new Integer ("30");


int op = obj1.compareTo(obj2);

if(op>0){

System.out.println("object1 is greater");

else if(op<0){

System.out.println("object2 is greater");

else{

System.out.println("object1 and object2 are equals");

Output

Addition of 14 and 16 is 30

String:30

Object 2 is greater

You might also like