Jump to content

2 Basic Questions from a beginner! -Java + iReport


petermere

Recommended Posts

1. In Java I have:

Class A {

private B b;

private int field 1;

}

Class B {

private int field 2;

private int field 3;

}

 

In my jrmx file, how can I access field 2 and field 3, having a list of A object.

 

2. In iReport, how can I distribute the columns evenly.

For example, I have:

FirstName Name Telephone.

I want all these 3 columns to have the same width.

 



Post Edited by petermere at 04/21/2010 14:20



Post Edited by petermere at 04/21/2010 14:28
Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 1 month later...

> In my jrmx file, how can I access field 2 and field 3, having a list of A object.

You can't.  A's reference to its B is private.  See the attached code.

 

 

Code:
File Test.java:import java.util.Arrays;import java.util.List;class A {    private B b;    private int field1;}class B {    private int field2;    private int field3;}public class Test {    void foo() {        List<A> list = Arrays.asList(new A());        A a = list.get(0);        int n = a.b.field2;    }}>javac Test.javaTest.java:19: b has private access in A        int n = a.b.field2;                 ^Test.java:19: field2 has private access in B        int n = a.b.field2;                   ^2 errors
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...