Object Class

Object Class with toArray Method

Object class is super class of all system define classes like Integer, Double, Float, String and many more. Object classes can store any types of data and then use easily.

In this blog, we will see how to store Integer object data store in Object array using toArray() method.

 

Let’s see Example on Object Class

 

import java.util.*;

class collection3

{

                public static void main(String args[])

                {

                                ArrayList<Integer> list1 = new ArrayList<Integer>();

                                list1.add(new Integer(67));

                                list1.add(new Integer(89));

                                list1.add(new Integer(45));

                                list1.add(new Integer(39));

                                list1.add(new Integer(90));

 

                                Object ob[] = list1.toArray();       // All List data now store in ob[] Array

 

                                int sum = 0;

                                for(int i=0;i<ob.length;i++)

                                {

                                                sum = sum + ((Integer)ob[i]).intValue();

                                }

                                System.out.println(“Sum = ” + sum);

                }

}

 

Output

Sum = 330

 

Video on simple Object Class Example


For more videos on Java visit our YouTube Channel


Earn Money Online

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

1136total visits,22visits today


mayank

Hello, I am Maddy a Java blogger, trainer and developer

Related articles

12 Comments

  1. January 3, 2017 - 5:49 pm

    Hey there! Do you know if they make any plugins to help with SEO?
    I’m trying to get my blog to rank for some targeted keywords but I’m not seeing
    very good results. If you know of any please share.

    Many thanks!

    • January 3, 2017 - 5:54 pm

      Just Install “Yoast SEO” Plugin and set all setting of that plug in…

      I got good result …

  2. January 6, 2017 - 3:47 pm

    Hey there, You have done an incredible job. I’ll definitely digg it and personally recommend to my friends.

    I’m sure they will be benefited from this web site.

  3. January 7, 2017 - 12:12 pm

    Hi there would you mind stating which blog platform you’re using?
    I’m going to start my own blog soon but I’m having a difficult time making a decision between BlogEngine/Wordpress/B2evolution and Drupal.

    The reason I ask is because your design and style seems different then most blogs and
    I’m looking for something completely unique.
    P.S Sorry for getting off-topic but I had to ask!

    • January 7, 2017 - 12:22 pm

      WordPress best…

  4. January 8, 2017 - 10:15 pm

    You need to be a part of a contest for one of the most useful websites online.
    I will highly recommend this blog!

  5. January 8, 2017 - 11:59 pm

    Very good information. Lucky me I ran across your site by chance (stumbleupon).
    I’ve book marked it for later!

    • January 9, 2017 - 12:51 pm

      thanks….

  6. January 9, 2017 - 12:33 pm

    A person necessarily lend a hand to make significantly
    articles I would state. This is the first time I
    frequented your website page and so far? I surprised with the analysis you made to create this actual post incredible.
    Fantastic activity!

  7. January 19, 2017 - 7:55 pm

    You should be a part of a contest for one of the best sites on the web.

    I’m going to highly recommend this blog!

  8. January 19, 2017 - 10:35 pm

    I every time spent my half an hour to read this web
    site’s posts daily along with a mug of coffee.

  9. January 19, 2017 - 10:53 pm

    This is my first time visit at here and i am actually happy to read all at single place.

Leave a Reply

Your email address will not be published. Required fields are marked *

Your comments (*)

Name (*)

Your full name please.

Email address (*)

Used for gravatar.

Website

Link back if you want.

Enter Captcha Here :*

Reload Image

EmailEmail
PrintPrint