Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write code in Java 3) Given an Arraylist of integers and an index position, write the method below which should return the integer in

Please write code in Java
image text in transcribed
3) Given an Arraylist of integers and an index position, write the method below which should return the integer in the Arraylist at the given index position if the argument value for pos is a valid index position. If pos is not a valid index position, the method should return a 1. Example calls and return values for the method are shown below. Write the code needed for the method to work as intended. getNumber ({6,8,2,4},1)8 getNumber (6,8,2,4},3)4 getNumber (6,8,2,4},5)1 getNumber ({6,8,2,4},3)1 public int getNumber( ArrayList nums, int pos) \{ \} 4) Given an integer array of length 2 , the method below should return true if the array does not contain 2 or 3 . If the array contains a 2, a 3, or both 2 and 3 then the method should return false, Example calls and return values for the method are shown below. Write the code needed for the method to work as intended. no23({4,5}) true no23 ({4,2}) false no23 ({3,5}) false public boolean no23( int[] nums)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

(b) What are the generators?

Answered: 1 week ago