Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8699057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:51:21+00:00 2026-06-13T01:51:21+00:00

Introduction I have the following class: public class Foo extends ArrayList<ElementsClass> implements Externalizable {

  • 0

Introduction

I have the following class:

public class Foo extends ArrayList<ElementsClass> implements Externalizable {
    Field field1 = new Field();
    Field field2 = new Field();

    ...
}

I implement the methods writeExternal and readExternal like this:

public void writeExternal(ObjectOutput out) throws IOException {        
    out.writeObject(field1);
    out.writeObject(field2);
}

public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException {
    field1 = (Field) in.readObject();
    field2 = (Field) in.readObject();
}

Observation

One of the fields is not Serializable that is why I implement Externalizable. I want to externalize only those things that I am able to.

Problem

Although I know that the ArrayList<ElementsClass> is serializable if ElementsClass is serializable, I don’t know how to externalize the class Foo itself.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T01:51:22+00:00Added an answer on June 13, 2026 at 1:51 am

    Try this:

    public void writeExternal(ObjectOutput out) throws IOException {        
        out.writeObject(super.toArray());
        out.writeObject(field1);
        out.writeObject(field2);
    }
    
    public void readExternal(ObjectInput in) throws IOException,ClassNotFoundException {
        Object[] arr = (Object[]) in.readObject();
        for (int k=0; k<arr.length; k++) super.add(arr[k]);
        field1 = (Field) in.readObject();
        field2 = (Field) in.readObject();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following class, listed below with static field of arrays. Could you
I have two of the following java classes (listed below) Class BookInfo declares static
I've been stumbling my way through jQuery and have the following: <form class=form method=POST
I'm following one of the MSDN Introduction to Windows Phone Development labs, and have
I have the following XML <School Version=30> <Math> <Lesson1 Type=Active>Introduction</Reset_mode> <Lesson2 Type=Active>Fundamentals</Reset_mode> </Math> </School>
I have the following class added to the My namespace in a .NET 3.5
Introduction When creating a new domain for Weblogic Portal 10.3.0.0, the following datasources are
I am implementing a WCF Data service that implements the following method: http://debugmode.net/2010/06/13/introduction-to-wcf-data-service-and-odata/ I've
I made a jsf project and have the following example from http://docs.openlayers.org/library/introduction.html but as
Introduction I am following the tutorial here and I have got to the last

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.