Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started