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

  • Home
  • SEARCH
  • 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 8782931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:41:46+00:00 2026-06-13T20:41:46+00:00

I am studying the Java and I am studying about concept of class type

  • 0

I am studying the Java and
I am studying about concept of class type of class

For example,
in the Print.java

public class Print{
    public ArrayList<data> list;
    public Print(){
        list = new ArrayList<data>();
    } 


    public void printIndexList() {
        for (data index : list) {
            System.out.format("\", index.name)
        }

        for (String definition : b.def) {
            System.out.format("%-6s", definition);
        }
    }

and In the data.java

public class  data{
     public String name
     public ArrayList<String> def;

     public data(){
         def = new ArrayList<String>();
     }
}

And, in the main.java,
I have String type ArrayList “defmain” and String type “mainname”

I would like to add the defmain and mainname in the list because I need to use printing function in the b.java

What I tried to do way

in the main.java, I have created: –

Print ia = new ptiny();

Array<Print> mainlist = new Array<Print>();

and.. tried to assign value in the list in the a.java

ia.list = mainlist;

however, it didn’t really work.
does anybody know a way to add a string value and an arraylist in the Arraylist which has type “a”?

thanks

  • 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-13T20:41:48+00:00Added an answer on June 13, 2026 at 8:41 pm

    Note that class names should start with uppercase letters. The following should work:

    A ia = new A();
    B ib = new B();
    ib.def.add("Test");
    ia.list.add(ib);
    ia.printIndexList();
    

    Note that I’m not assigning any list. I’m adding elements to lists.

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

Sidebar

Related Questions

I am pretty new to Java and Maven and today was studying about maven,
Studying Java, I've come across generic methods . public <T> void foo(T variable) {
I was studying about polymorphism. I couldn't determine the analogy in Java about these
I am learning java, and studying the following example from sun.com. import java.io.*; import
I am studying Java concurrency right now. I have a question about synchronized and
I am studying Java and sorting. I have a question about tracking the index
I'm studying for Java Programmer Certification (SCJP) exam. A question about exceptions, when handle
I just saw this data-structure on the Java 6 API and I'm curious about
I'm new at object oriented programming and we are studying on a Java project.
So I was studying Abstract class in java, and when I was reading other

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.