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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:01:13+00:00 2026-05-23T15:01:13+00:00

I have class: static class AnotherClass { int number; String isPrime; public int getNumber()

  • 0

I have class:

static class AnotherClass {
        int number;
        String isPrime;

        public int getNumber() {
            return number;
        }

        public String getPrime() {
            return isPrime;
        }

        public void setNumber(int number) {
            this.number = number;
        }

        public void setPrime(String prime) {
            isPrime = prime;
        }

    }

and in main class i have:

    List<AnotherClass> listx = new ArrayList<AnotherClass>();//just a arraylist

for (int z = 0; z < howManyQuestions; z++) {//in loop i add class with fields
            AnotherClass classx = new AnotherClass();
            int valuex = Integer.parseInt(keyboardkey.readLine());

            classx.setNumber(valuex);//save value in this class

            String answer = Check(valuex);//i just get here string answer YES NO
            classx.setPrime(answer);

            listx.add(classx);//and i add this two fields of class to list

            System.out.println();

        }
INPUT: (i add value and check if it was input before)
3
4
3

OUTPUT
NO
NO
YES

How can i check if, for example value "3" is containing by list?
  • 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-23T15:01:13+00:00Added an answer on May 23, 2026 at 3:01 pm

    1 AnotherClass must implement equals() (and implement hashCode() accordingly).

    2 Use method contains(Object o) from listx.

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

Sidebar

Related Questions

I have the following class: public abstract class AbstractParent { static String method() {
i have a class with a static public property called Info. via reflection i
Let's say that I have a class Foo: public class Foo { public static
I have a public static class in which I would like to have a
I have a method which looks like this public void setDayIntervals(Days day, List<HourRange> ranges)
I have a method that looks like this public static <T extends MyClass, X
I have a static class with number of different methods. I have another class,
I have a class, lets say CAppPath which has a static method: public: static
I have this object Object1 defined as public Object1(String item, List<Object2> obj2) in a
I have this class hierarchy: public interface ISR { } public interface ICU {

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.