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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:12:27+00:00 2026-06-15T12:12:27+00:00

So here is my methods: public static ArrayList collectSchedule(ArrayList schedule, ArrayList list, int counter)

  • 0

So here is my methods:

public static ArrayList collectSchedule(ArrayList schedule, ArrayList list, int counter)
{
    ((ArrayList) list.get(counter)).add(schedule);
    System.out.println(list);
    return list;
}
public static ArrayList getClassInfo(int count)
{
    Scanner stdIn = new Scanner (System.in);
    String userInput;
    System.out.print("Enter the name of class #" + count + " : ");
    userInput = stdIn.nextLine();
    ArrayList x = getClassTime();
    x.add(0, userInput);
    x.add(1, getClassLength());
    x.add(2, getDayOfTheWeek());
    return x;
}

So I take the value “x” from getClassInfo (which is an ArrayList) and input that into the method collectSchedule along with a number (the index of where I want it) and another ArrayList (lets call it “schedule”). I add “x” (the ArrayList) to the ArrayList “schedule”. If I print out “x” it will show all values of “schedule”. (note: I add multiple different instances of “x” to schedule!). So if I add 3 different “x’s” to “schedule”, it will print them all out separately ( [x, x, x][x, x, x][x, x, x] ). I’m having troubles getting only a single value of “x” from “schedule”.

I thought this code would work but it gives me an error at compilation.

public static void creation(ArrayList list)
{
    System.out.println((schedule.get(0)).x().get(1));
}

Can anyone help me where I’ve gone wrong?
I read something about using an object? But not sure how!

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-15T12:12:28+00:00Added an answer on June 15, 2026 at 12:12 pm

    You’ll find working with collections a lot easier to do if you start using generics, i.e. List<List<String>> myList. Additionally, why not make some actual classes that store typed values instead of relying on indexed lists?

    That aside….

    System.out.println((schedule.get(0)).x().get(1));
    

    If the type of schedule is ArrayList, then schedule.get(0) is going to return something of type Object, unless you perform an explicit cast. Since Object has no method x() that’s going to generate an error. You can typically narrow this stuff down yourself by not including so many chained function calls on one line. Doing so makes it difficult to tell what a given error is referring to.

    If schedule were declared as List<List<String>> or even List<List<Object>> then you’d be able to do this:

    List<String> classInfo = schedule.get(0);
    String classLength = classInfo.get(1);
    System.out.println(classLength);
    

    Which I think is what you’re actually aiming for

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

Sidebar

Related Questions

Here's the method: public static String CPUcolor () { System.out.println (What color am I?)
here's the method: public static int chooseStrat () { String[] strats = new String[1]
I am using Jon Skeet's ReadFully method implemented here: public static byte[] ReadFully(Stream stream)
Here's my extension method for invoke on a control: public static void Invoke<T>(this T
public class A { //some fields (may not only primitive types) and methods here}
Not sure what's going on here... My controller methods looks like this: [HttpGet] public
Here is my class (product.cs) where is the method to insert the image: public
I have a method which requests external webservices and returns json here: public string
I'm possibly confusing rack and capybara methods here let!(:admin){FactoryGirl.create(:admin)} # test passes describe visiting
Referring to the first answer about python's bound and unbound methods here, I have

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.