Long Wrapper Class

Long Wrapper Class:

  • Long Class is presented in java.lang package.
  • java.lang.Long class is used to represent primitive Long Value to Long object.

Long Class :

Float Class Definition

  1. public final class Long
  2. extends Number 
  3. implements Comparable<Long>



Constructors:

1.Long(long value):
  • The Constructor Long(long value) represents the specified long argument.

2.Long(String s):
  • The Constructor Long (String s) represents the long value indicated by the String parameter.

Methods:

1.public static int bitCount(long i); Program:

  1. package com.instanceofjava; 
  2. import java.lang.*; 
  3.  
  4. public class LongExample { 
  5.  
  6. public static void main(String[] args) {
  7.  
  8.   long l = 4561; 

  9.  System.out.println("Number = " + l);
  10.  System.out.println("Binary = " + Long.toBinaryString(l));
  11.  System.out.println("Number of one bits = " + Long.bitCount(l));
  12.  
  13. }
  14. }

Output:
  1. Number = 4561 
  2. Binary = 1000111010001 
  3. Number of one bits = 6

2.public byte byteValue():

This method returns value of long as byte.

Program:

 

  1. package com.instanceofjava;
  2.  import java.lang.*;

  3. public class LongExample {

  4. public static void main(String[] args) {

  5.  Long obj = new Long(30);

  6.  byte b = obj.byteValue();
  7.  System.out.println("Value of b = " + b);
  8.  
  9.  }
  10. }


Output:
  1. Value of b = 30

3.public int compareTo(Long anotherLong):

Program:

  1. package com.instanceofjava;
  2. import java.lang.*;

  3. public class LongExample {

  4. public static void main(String[] args) {
  5.  
  6.    Long a = new Long(63255);
  7.   Long b = new Long(71678);
  8.  
  9.    int result=  a.compareTo(b);
  10.    ifresult> 0) {
  11.    System.out.println("a is greater than b");
  12.    }
  13.    else ifresult< 0) {
  14.    System.out.println("a is less than b");
  15.    }
  16.    else {
  17.    System.out.println("a is equal to b");
  18.    }
  19.  
  20.    }
  21. }




Output:
  1. a is less than b

4.public static Long decode(String nm) throws NumberFormatException:

Program:


  1. package com.instanceofjava;
  2. import java.lang.*;

  3. public class LongExample{

  4.  public static void main(String[] args) {

  5.    Long l = new Long(10);
  6.    String str = "57820";
  7.    System.out.println("Number = " + l.decode(str));
  8.  
  9.   }
  10. }

Output:
  1. 57820




Float Wrapper Class

  • Float class is presented in java.lang package
  • java.lang.Float class is used to represent primitive float value to Float object.

Float Class Definition

  1. public final class Float
  2. extends Number
  3. implements Comparable<Float>

Float Class Constructors

1.public Float(double value)


  1. package com.instanceofjavatutorial;
  2.  
  3. public class FloatDemo {
  4.  
  5. public static void main(String[] args) {
  6.  

  7.  Float f = new Float(22.56d);
  8.   System.out.println(f);
  9.  
  10.  
  11. }
  12. }

Output:
  1. 22.56


2.public Float(float value)


  1. package com.instanceofjavatutorial;
  2.  
  3. public class FloatDemo {
  4.  
  5. public static void main(String[] args) {
  6.  

  7.  Float f = new Float(22.56f);
  8.   System.out.println(f);
  9.  
  10.  
  11. }
  12. }

Output:
  1. 22.56


3.public Float(String s) throws NumberFormatException


  1. package com.instanceofjavatutorial;
  2.  
  3. public class FloatDemo {
  4.  
  5. public static void main(String[] args) {
  6.  

  7.  Float f = new Float("22.56f");
  8.   System.out.println(f);
  9.  
  10.  
  11. }
  12. }

Output:
  1. 22.56

Float Class Methods:

1.public static Float valueOf(String s) throws NumberFormatException 

  • This method used to convert string value to float value. If the string contains non parsable value then it throws NumberFormatException 

  1. package com.instanceofjavatutorial;
  2.  
  3. public class FloatValueOfDemo {
  4.  
  5. public static void main(String[] args) {
  6.  
  7.  String str="56.32";

  8.  Float f = Float.valueOf(str);
  9.   System.out.println(f);
  10.  
  11.  
  12. }
  13. }

Output:
  1. 56.32

2.public String toString()
  • This method returns String value from Float Object.

  1. package com.instanceofjavatutorial;
  2.  
  3. public class FloatValueOfDemo {
  4.  
  5. public static void main(String[] args) {
  6.   
  7.  Float f = new Float("12.3")
  8.  String str=f.toString();

  9.   System.out.println(str);
  10.  
  11.  
  12. }
  13. }



Output:
  1. 12.3

3.public static float parseFloat(String s) throws NumberFormatException

  • This method returns float value from string object. If string doesnt contains parsable float value then throws NumberFormatException 

  1. package com.instanceofjavatutorial;
  2.  
  3. public class FloatDemo {
  4.  
  5. public static void main(String[] args) {
  6.  
  7.  String str="20";

  8.  Float f = Float.parseFloat(str);
  9.   System.out.println(f);
  10.  
  11.  
  12. }
  13. }

Output:
  1. 20.0



Character Class

  • Character class is presented in java.lang package
  • java.lang.Character class is used to represent primitive character value to character object.

Character Class Definition:

  1. public final class Character
  2.  extends Object 
  3. implements Serializable, Comparable<Character>

Character Class Constructors:

1. public Character(char value)
  • Character class having only one constructor which accepts char primitive value.

Java Program to convert char primitive value to Character Object.

  1. package com.instanceofjavatutorial;
  2.  
  3. public class CharacterDemo {
  4.  
  5. public static void main(String[] args) {
  6.  

  7.  Character ch = new Character ('a');
  8.   System.out.println(ch);
  9.  
  10.  
  11. }
  12. }

Output:
  1. a

 Character Class Methods:

1.public char charValue()

  • This method returns the primitive char value from the Character object.

Java code to get char primitive value from Character Object.

  1. package com.instanceofjavatutorial;
  2.  
  3. public class CharacterCharValueDemo {
  4.  
  5. public static void main(String[] args) {
  6.  

  7.  Character ch = new Character ('a');
  8.   char c=ch.charValue();

  9.  System.out.println(c);
  10.  
  11. }
  12. }

Output:
  1. a

2.public static String toString(char c) :

  • toString(char c) method present in Character class accepts "char" primitive values and returns String objects representing that character.
Java code to convert char primitive value to String object

  1. package com.instanceofjavatutorial;
  2.  
  3. public class CharactertoStringDemo {
  4.  
  5. public static void main(String[] args) {

  6.   char ch ='I';
  7.  
  8.   String str="";
  9.  
  10.   str=Character.toString(ch);
  11.  
  12.   System.out.println(str);
  13. }
  14. }

Output:
  1. I

3.public static Character valueOf(char c)

  • valueOf(char c)  is static method present in Character class used to convert char value to Chraracter object.
  • It accepts char primitive value and returns Character object

Java code to convert char primitive value to String object

  1. package com.instanceofjavatutorial;
  2.  
  3. public class CharactervalueOfDemo {
  4.  
  5. public static void main(String[] args) {

  6.   char ch ='S';
  7.  
  8.   Character chobj='';
  9.  
  10.   chobj=Character.valueOf(ch);
  11.  
  12.   System.out.println(chobj);
  13. }
  14. }

Output:
  1. S
4.public static char toUpperCase(char ch)

  • toUpperCase(char ch) static method present in Character class used to convert a character to uppercase.
  • It accepts a character and returns same character in uppercase.


Java code to convert char primitive value to uppercase

  1. package com.instanceofjavatutorial;
  2.  
  3. public class CharacteruppercaseDemo {
  4.  
  5. public static void main(String[] args) {

  6.   char ch ='a';
  7.  
  8.   char c=Character.valueOf(ch);
  9.  
  10.   System.out.println(c);
  11. }
  12. }



Output:
  1. A

5.public static char toLowerCase(char ch) 

  •  toLowerCase(char ch) static method present in Character class used to convert a character to lowercase.
  • It accepts a character and returns same character in lowercase.


Java code to convert char primitive value to lowercase

  1. package com.instanceofjavatutorial;
  2.  
  3. public class CharacterlowercaseDemo {
  4.  
  5. public static void main(String[] args) {

  6.   char ch ='L';
  7.  
  8.   char c=Character.valueOf(ch);
  9.  
  10.   System.out.println(c);
  11. }
  12. }

Output:
  1. l



Integer Wrapper class

  • Integer  class is present in java.lang package.
  • java.lang.Integer  is used to represent integer primitive value in form of object.

Class Definition

  1. public final class Integer
  2. extends Number 
  3. implements Comparable<Integer>

Integer Class Constructors

1.public Integer(int value):
  • It takes int primitive value as an argument.
Java code to convert int primitive to Integer object


  1. package com.instanceofjavatutorial;
  2.  
  3. public class IntegerDemo {
  4.  
  5. public static void main(String[] args) {
  6.  


  7.  Integer obj=new Integer (37);
  8.  
  9.  System.out.println(obj);
  10.  
  11.  
  12. }
  13. }

Output:
  1. 37

2.public Integer(String s)  throws NumberFormatException:

  • It takes String value as an argument. 

Java code to convert String to Integer object


  1. package com.instanceofjavatutorial;
  2.  
  3. public class IntegerDemo {
  4.  
  5. public static void main(String[] args) {
  6.  


  7.  Integer obj=new Integer ("123");
  8.  
  9.  System.out.println(obj);
  10.  
  11.  
  12. }
  13. }

Output:
  1. 123

Integer Class Methods:

3.public static int parseInt(String s) throws NumberFormatException :
  • This method takes String as an argument and converts to the int value
  • Static method present in Integer Class used to parse the string to the corresponding int value.in
  • We can use this method by class name Integer.parseInt("number").
  • If the String contains non numeric value then this method throws NumberFormatException 

 Java Program to parse a string or convert String to Integer value

  1. package com.instanceofjavatutorial;
  2.  
  3. public class IntegerParseIntDemo {
  4.  
  5. public static void main(String[] args) {
  6.  

  7.  int x= Integer.parseInt("34");
  8.   System.out.println(x);
  9.  
  10.  int y=  Integer.parseInt("56");
  11.    System.out.println(y);
  12.  
  13.  int z=  Integer.parseInt("98");
  14.  System.out.println(z);
  15.  
  16. }
  17. }

Output:
  1. 34
  2. 56
  3. 98
4.public int intValue()

  • This method returns the int value from the Integer Object.
  • obj.intValue()- returns a int value of Object obj.



Java Program to get int value from a Integer Object.

  1. package com.instanceofjavatutorial;
  2.  
  3. public class IntegerIntValueDemo {
  4.  
  5. public static void main(String[] args) {
  6.  

  7.  Integer obj= new Integer(25);

  8.  
  9.  int y= obj.intValue();
  10.  
  11.  System.out.println(y);
  12.  
  13. }
  14. }

Output:
  1. 25

3.public int compareTo(Integer anotherInteger) 

  •  This method is used to compare two Integer Objects and returns int value
  •  0- Integer is equal to the argument Integer
  • < 0 if this Integer is numerically less than the argument Integer
  • > 0 if this Integer is numerically greater than the argument

Java Program to compare two Integer Objects.

  1. package com.instanceofjavatutorial;
  2.  
  3. public class IntegercompareToDemo {
  4.  
  5. public static void main(String[] args) {
  6.  

  7.    Integer obj1 = new Integer("34");
  8.    Integer obj2 = new Integer("08");
  9.  
  10.   int val =  obj1.compareTo(obj2);
  11.  
  12.    if(val > 0) {
  13.  
  14.    System.out.println("obj1 is greater than obj2");
  15.  
  16.    }
  17.    else if(val < 0) {
  18.  
  19.    System.out.println("obj1 is less than obj2");
  20.  
  21.    }
  22.    else {
  23.  
  24.    System.out.println("obj1 is equal to obj2");
  25.  
  26.    }
  27. }
  28. }

Output:
  1. obj1 is greater than obj2


4.public float floatValue()

  • This method used to convert integer value to float value.

Java Program to convert Integer to float

  1. package com.instanceofjavatutorial;
  2.  
  3. public class IntegerfloatValueDemo {
  4.  
  5. public static void main(String[] args) {
  6.  

  7.    Integer obj1 = new Integer("34");
  8.    Integer obj2 = new Integer("23");
  9.    
  10.     float f 1= obj1.floatValue();
  11.     float f 2= obj2.floatValue();
  12.  
  13.    System.out.println(f1);
  14.    System.out.println(f2); 

  15. }
  16. }

Output:
  1. 34.0
  2. 23.0

5.public String toString()

  • This method used to convert Integer to string object.

Java Program to convert Integer to String Object.

  1. package com.instanceofjavatutorial;
  2.  
  3. public class IntegerfloatValueDemo {
  4.  
  5. public static void main(String[] args) {
  6.  

  7.    Integer obj1 = new Integer("12");
  8.    Integer obj2 = new Integer("34");
  9.    
  10.     String  str1= obj1.toString();
  11.     String  f 2= obj2.toString();
  12.  
  13.    System.out.println(str1);
  14.    System.out.println(str2); 

  15. }
  16. }

Output:
  1. 12
  2. 34

Byte Wrapper Class

Byte Wrapper class Programs:


  • The java.lang.Byte class is used represent byte primitive value in form of Byte Object

  1. public final class Byte
  2. extends Number implements Comparable<Byte>

Byte Class Constructors:


1.Byte(byte value)
2.Byte(String s)

Byte Class Methods:

  • public byte byteValue() returns the value of this Byte as a byte.

Program:

  1. package com.instanceofjavatutorial;

  2. import java.lang.*; 

  3. public class ByteClass {

  4. public static void main(String[] args) {

  5.       Byte a;
  6.       a = new Byte("100");

  7.       byte t;
  8.       t = a.byteValue();

  9.       String s= "byte value of Byte object " + a + " is " + t;

  10.       System.out.println( s);

  11.    }
  12. }


Output:
  1. byte value of Byte object 100 is 100












Oracle and the Community Celebrate 20 Years of Java

Java 20 years


Oracle and the Community Celebrate 20 Years of Java 
  • Look Ahead to How Java Will Continue to Transform the Way We Work and Live Oracle, users and the development community worldwide are celebrating 20 years of Java this year. Today, Java serves as the critical backbone of software that touches both our work and personal lives. From innovations in enterprise big data, cloud, social, mobile and the Internet of Things, to connected cars, smartphones and video games, Java continues to help developers push the boundaries in technology innovation.

java 20 years



Evolution of the World’s #1 Programming Language
 
  • Introduced in 1995, Java is the programming language of choice for 9 million developers and today powers 7 billion devices. Improving road and air safety, collecting information from the world’s oceans for science applications, increasing grain crop quality and quantifying to help feed the hungry, simulating the human brain and musculoskeletal system, and gaming are some of the intriguing projects worldwide that use the Java technology. 
  • Enterprise developers can choose from an ecosystem of 30 Java EE 6 and Java EE 7 compatible implementations from 12 vendors. Additionally, more than 125 million Java-based media devices have been deployed and over 10 billion Java Cards have been shipped since Java’s introduction.
  • Under the stewardship of Oracle, two major platform releases including Java 7 and Java 8 have been delivered, with Java 9 slated for 2016. The Java Community Process (JCP) is more open and transparent than ever before, and serves as an integral element of community participation in the ongoing evolution of the technology. The OpenJDK Community, the place to collaborate on an open-source implementation of the Java Platform, Standard Edition, is continuously attracting new contributors to its already broad base of participation.
  • In March 2014, Oracle announced availability of Java SE 8 after receiving final approval in the Java Community process. This release, which included the largest upgrade to the Java programming model since the platform was introduced in 1995, was developed collaboratively in the OpenJDK Community. Soon after, in April 2014, the Java Platform, Micro Edition 8 (Java ME 8) and the related releases of Oracle's Java Embedded products were also made available after final approval in the Java Community Process.  With a consistent Java 8 platform across embedded devices, desktops, data centers and the cloud, customers can deploy applications faster; process and analyze in-flight data; and act on events as quickly as they occur.


java on cloud IOT

Ushering in the Next Era of Java 
  • Oracle and the Java community are now focused on delivering new innovations in Java 9. The key planned feature of this release is Project Jigsaw, which aims to modularize the platform in order to make it scalable to a wider range of devices, make it easier for developers to construct and maintain libraries and large applications, and improve security, maintainability, and performance. Other features slated for Java 9 include the Java Shell, an interactive tool for evaluating snippets of Java code; a new HTTP client API to support HTTP/2 and Web Sockets; a port to the ARM AArch64 architecture on Linux; and a variety of updates to existing APIs along with some significant performance improvements.
  • Visit the Duke’s Choice Award winners to see the remarkable work being done today by the Java community. 

“Java has grown and evolved to become one of the most important and dependable technologies in our industry today. Those who have chosen Java have been rewarded many times over with increases in performance, scalability, reliability, compatibility, and functionality.The Java ecosystem offers outstanding libraries, frameworks, and resources to help programmers from novice to expert alike.  The development of Java itself occurs in the transparent OpenJDK community.  With the considerable investment from Oracle and others in the community, we look forward to the next 20 years of Java’s evolution and growth.”

- Georges Saab, vice president of development, Java Platform Group, Oracle


 "IBM is celebrating Java's 20th anniversary as one of the most important industry led programming platforms spanning mobile, client and enterprise software platforms. IBM began its commitment to Java at its inception over two decades ago, and has seen the Java ecosystem and developer community bring unsurpassed value to the investments our clients have made in their Java based solutions. IBM looks forward to the next 20 years of growth and innovation in the Java ecosystem including Mobile, Cloud, Analytics and Internet of Things."  


-Harish Grama, vice president, Middleware Products, IBM Systems


“Programming languages don’t always live a long life, and those that do, don’t always enjoy a healthy one. But Java has stood the test of time and the test of the vast range of applications using it, from large enterprise systems to small device games.”

- Al Hilwa, IDC program director for Application Development Research





For Every 2 years Release will be there for java Under Oracle

  • The next version of java is Java 9 is going to be released on 2016 itself.  This shows how the team is working to ensure that there is everything for us to develop. 
  • Oracle and the java community now focusing on key project of Java 9 Project Jigsaw which helps us to build and maintain libraries and large applications and improves security maintainability and performance.

Get the education you need at better price

  • Oracle Training and Certification is offering 20 percent discount on all Java certification exams. The offer available globally is now open and expires on December 31, 2015.  at the time of registration you need to provide promotional code  as Java20
  • Clicke here for more details

Bloggers Meet At Oracle Hyderabad:

  • Today we attended an event organized by oracle on the occasion of "20 years of java".
  • One week back we got a message on instanceofjava Facebook page from oracle person 
    Gopal Kommuri saying that "I am writing on behalf of Oracle and trying to reach out to you to discuss about a bloggers meet we are planning to do in the next week".
  • I was surprised  because we www.instanceofjava.com are so young compared to others  but we are doing good on java and helping people like you and growing fast.
  • Anyway we are happy and said for sure will be attending the event.
  • Today june 13th 2015 morning 11 o clock we reached oracle office expecting that it was a big corporate event with lot of people.
  • Got a warm welcome from  Anita George and we entered into the meeting hall.
  • There are few Bloggers and higher officials.
  • Ms. Vandana Shenoy, Directory Corporate Communications, Oracle gave a warm welcome speech and introduced the presenters.
  • Sanket Atal, Group Vice President, India R&D, Oracle and he gave presentation titled “Java – 20 years of Innovation”. It was a very nice speech starting from how Java was created to the present day and how the future is promising for that how the oracle is doing things better to keep java alive.
  • Prior to Oracle Sanket held senior positions at MakeMy Trip and CA Technologies as CTO & Head of  Technology Center. He earlier worked with oracle in 1997 for over 13 years . He was the founding member of the team that setup the R&D centre for Oracle in the City of Portland Oregon , US.



                    • Inspiring and encouraging speech by Harshad Oak Founder , IndicThreads&Rightrix Solution , First Java Champion in India , Oracle ACE Director.
                    • Harshad has written many books on java including Oracle Jdeveloper 1og, Empowering J2EE Development, Pro Jakartha commons and J2EE 1.4 Bible.



                    • Innovative presentation by  Debraj Dutta  winner of the Oracle IoT Developer Challenge
                    • He showed us "Bot-So" which is taking photos and videos and calculating temperature by responding to twitter tweets designed using java 8 ,twitter 4j and Google drive  built on RaspberryPi hardware and Java platform.
                    • Bot-So is a smart social robot that interacts with you via twitter. The robot can be developed for remote home surveillance by sending commands via twitter. A tweet sent to the robot will trigger it to survey a space when the motion detector is triggered.
                    • He tweeted commands like "take a picture "  and it took a picture of us. it was amazing
                    • Java - Internet of everything.

                    • Here its Bot-So. (Robot-social)
                    • It can take a picture and video by rotating 120 degrees


                    • And we celebrated 20th java birth day by cutting a nice cake.

                    Happy birth day java
                    • After that had a group photo and nice lunch with team. Had a nice discussion with Sreekanth Narayanan.
                    •  met other bloggers and enjoyed the session and found it informative and encouraging.
                    • Its me Saidesh 1st from left and Indira second from right
                    Java 20 years




                    java 20 years




                    Select Menu