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 4574322
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:54:25+00:00 2026-05-21T19:54:25+00:00

I have the following problem: class POJO implements Serializable{ int[] a = new int[2];

  • 0

I have the following problem:

class POJO implements Serializable{
    int[] a = new int[2];
    int b;
}

Server:

printThere(ArrayList<POJO> list) throws RemoteException{
    for(POJO obj:list)
      System.out.println(obj.a[0]+" "+obj.a[1]+" "+obj.b);\\<-----THERE LINE
}

Client:

main(){
    POJO o1 = new POJO();
    o1.a[0] =1;
    o1.a[1] =2;
    o1.b= 11;
    POJO o2 = new POJO();
    o2.a[0] =10;
    o2.a[1] =20;
    o2.b= 111;
    ArrayList<POJO> list = new ArrayList<POJO>();
    list.add(o1);
    list.add(o2);
    for(POJO obj:list)
        System.out.println(obj.a[0]+" "+obj.a[1]+" "+obj.b);\\<-----HERE LINE
    server = proxy.lookup("server");
    server.printThere(list);
}

Here the lines print as follows:

1 2 11  
10 20 111

There the lines print as follows:

1 2 111  
10 20 111

Why am I losing the value of b in one object? I tried using a Vector<POJO> and a POJO[] in the remote method but got the same result.

  • 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-05-21T19:54:26+00:00Added an answer on May 21, 2026 at 7:54 pm

    I don’t see the problem. That said, I think you will be able to get to the bottom of it quite quickly. Here’s my suggestion:

    Gradually omit pieces from your program. After each step run the code and see if the problem persists. Each such “experiment” will give you valuable details about the cause of the problem. Eventually you want to be able to detect what element in your code is causing the problem.
    Here are some steps to take along the way:

    • Does the problem occur if you remove o2 from your code?
    • Does the problem occur if you create o2 but do not add it to list?
    • Does the problem occur if you remove the a field from the POJO class?
    • Does the problem occur if you change a into a single element array (a = new int[1])?
    • Does the problem occur if you change a from an array to a (say) Integer?
    • Does the problem occur if you change b‘s type from int to some other primitive?
    • Does the problem occur if you change b‘s type from int to some other non-primitive type (say: String or java.util.Date)?
    • Does the problem occur if you change the order of o1 and o2 inside the list (i.e., add(o2) and then add(o1)) ?
    • Does the problem occur if you change the signature of printThere() such that it takes (say) to POJO parameter (instead of a single ArrayList)?
    • Does the problem occur if you change the order of fields in the print (e.g., first print b, then a[1], then a[0])?
    • …

    Usually, after applying several “transformation” steps such as these, I gather enough information to identify the root cause. On top of that I try to reduce the scope. If I find that the problem occurs even if o2 is omitted then I keep it away, proceeding with a smaller program that is more easy to understand.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good day, I have the following problem: class B extends class A and methods
I have the following problem: I have the class: class Word(object): def __init__(self): self.id
I have the following problem with inheritance and templates: class Base {}; class Deriv
I have the following problem. I have a class named A in which I
I have the following tricky problem: I have implemented a (rather complicated) class which
Today I ran into the following problem with NUnit. I have a class, that
Let's say I have following POJO's using Hibernate. public class User { private String
I have following problem. In my view model I defined some list properties as
I have the following cyclic dependency problem I am trying to solve: typedef std::map<int,
I have the following problem in Java: I have a base class and a

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.