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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:40:25+00:00 2026-05-16T21:40:25+00:00

I am trying to get an array to take a variable number of objects

  • 0

I am trying to get an array to take a variable number of objects as input. I am new to programming so I apologize in advance.

Here is my code:

public class Rating{
    double [] Ratings;
    int CustomerID;
    int Domain;

    public Rating (int id, int d, double [] x) {
        double [] Ratings = x;
        int CustomerID=id;
        int Domain=d;
    }
}

public class All_user{
    double [] All_users;

    public All_user(Rating...argument) {
        double [] All_users={Rating...argument};
    }
}

However, I am get this error associated with double[] All_users={Rating..arguments);:

    Multiple markers at this line
 - Syntax error on token "...", . expected
 - arguments cannot be resolved or is 
  not a field

Any thoughts? Thanks in advance!

  • 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-16T21:40:25+00:00Added an answer on May 16, 2026 at 9:40 pm

    The problem comes in your All_user class constructor; you’re trying to set… something… of type Ratings[] to a class member of type double[]

    You could do one of the following :

    1- Have your All_user‘s constructor receive an array (or variable-length arguments) be instances of Rating and simply assign it to the class member (an array) of the same type :

    public class All_user{
        Rating [] All_users;
    
        public All_user(Rating...argument) {
            All_users = argument;  // arguments is a Rating[]
        }
    }
    

    or collect all values (double Ratings) from each Rating and map them into an array

    public class All_user{
        double [] All_users;
    
        public All_user(Rating...argument) {
            ArrayList<Double> ratings = new ArrayList<Double>();
            for (Rating r : argument) {
                for (double d : r.Ratings) ratings.add(d);
            }
            All_users = new double[ratings.size()];
            for (int i=0; i<ratings.size(); i++) All_users[i] = ratings.get(i);
        }
    }
    

    I think the latter is what you are trying to do. Also, note that your Rating class could also be rewritten as

    public class Rating{
        double [] Ratings;
        int CustomerID;
        int Domain;
    
        public Rating (int id, int d, double...x) {
            double [] Ratings = x;
            int CustomerID=id;
            int Domain=d;
        }
    }
    

    FYI: The variable-length argument is always the last one in the declared arguments. More on varargs here and here.

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

Sidebar

Ask A Question

Stats

  • Questions 531k
  • Answers 531k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer As far as I could understand it, try this: $('a#slickShow').click(function(){… May 16, 2026 at 11:47 pm
  • Editorial Team
    Editorial Team added an answer You need to URL encode just the query argument value;… May 16, 2026 at 11:47 pm
  • Editorial Team
    Editorial Team added an answer Lot of questions: In the main method are three class… May 16, 2026 at 11:47 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm trying to make a PHP script that will take a potentially infinite number
I am trying to get a function in JAVA to take a value in
I've started to play around with PowerShell and am trying to get it to
I'm trying to process this array, first testing for the presence of a check,
I'm trying to take the results of a view - using the function views_get_view_result()
I'm trying to write a method to take a multiline tab-delimited file and return
here is what i am trying to do: NSMutableArray *objectNames = [[NSMutableArray alloc] init];
I have a txt file that has a change-log.I'm trying to display the new
I'm trying to learn the basic jist of a Semaphore in the Dining Philosopher
I'm trying to create a very simple database abstraction, one part of it using

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.