यदि मैं आपका प्रश्न समझता हूं, तो आप यह जांचना चाहते हैं कि कोई सरणी सूची पहले से मौजूद है और पूर्णांक मान है या नहीं। यदि ऐसा है, तो आप ArrayList.contains() का उपयोग कर सकते हैं।
नमूना यहाँ कोड:
ArrayList list = new ArrayList();
int x = 4, y = 7;
int z = x;
list.add(x);
//List contains the value 4, which is the value stored in z
//Program will output "List contains 4"
if(list.contains(z))
{
System.out.printf("List contains %d\n", z);
}
else
{
System.out.printf("List does not contain %d\n", z);
}
//List contains the value 7, which is the value stored in y
//Program will output "List does not contain 7"
if(list.contains(y))
{
System.out.printf("List contains %d\n", y);
}
else
{
System.out.printf("List does not contain %d\n", y);
}
आप कुछ भी है कि आप अब तक की कोशिश की है साझा करने के लिए करना चाहते हैं? – dasblinkenlight
ऐसे प्रश्न पूछने से पहले ArrayList API पर एक नज़र डालें। यह नोटिस करने के लिए तुच्छ है कि ArrayList क्लास में इसकी परिभाषा से एक() विधि है। – Juvanis