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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:26:52+00:00 2026-06-06T22:26:52+00:00

Is it possible to do the following? List<Object o, Object p> listWithTwoObjects; I want

  • 0

Is it possible to do the following?

List<Object o, Object p> listWithTwoObjects;

I want to retrieve data from a database and save it into this list, concretely in this way

Query query = "retrieve all posts and username, which this user posted";
List<Object o, Object p> userAndPost = query.getResultList();

o is the username, and p is the post. I can then render this to my template and show each post with its user.

My question is about the List with two Objects inside. Is it possible and if yes, how and where is the documentation for this?

  • 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-06T22:26:53+00:00Added an answer on June 6, 2026 at 10:26 pm

    You can define a Pair class as follows:

    public class Pair
    {
        String username;
        int post;
    
        public Pair(String username, int post)
        {
            this.username = username;
            this.post = post;
        }
    }
    

    and then simply use List<Pair>, for example:

    List<Pair> pairs = new ArrayList<Pair>();
    pairs.add(new Pair("doniyor", 12345));
    
    // ...
    
    Pair p = pairs.get(0);
    System.out.pritnln(p.username); // doniyor
    System.out.pritnln(p.post); // 12345
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following code: case class ChangeSet(field:String, from:Object, to:Object) private var changed:List[ChangeSet] = Nil
I have the following query which returns a list of questions and the possible
Is it possible to store multiple different class types in a single std::list object?
Possible Duplicate: Loop through Json object { data: [ { name: Jen, id: 1
I want to create a list of class instances that automatically updates itself following
Is it possible to get cascade delete on this object model? public class Entity
I have the following ApplicationScoped bean package es.caib.gesma.gesman.data; import java.util.List; import javax.annotation.PostConstruct; import javax.ejb.EJB;
Is is possible to combine a List initializer and object initializer at the same
Is is possible to convert following into a simpler more readable linq or lambda
I'm not sure if this is possible in LINQ, but I have the following

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.