Question: Help in Java, please my code is finished but I can't figure out why my code is not working, the error I get is java:

Help in Java, please

my code is finished but I can't figure out why my code is not working, the error I get is java: variable q might not have been initialized

package cpsc2150.MyDeque; import java.sql.Array; import java.util.*; public class DequeApp { public static void main(String[] args) { IDeque q; int uI = 0; System.out.println("Enter 1 for array implementation or 2 for List implementation"); Scanner sc = new Scanner(System.in); uI = sc.nextInt(); while (uI < 1 || uI > 2) { System.out.println("Invalid number. Please enter 1 for array implementation or 2 for List implementation"); uI = sc.nextInt(); } if(uI == 1) { //q turns into an array //System.out.println("yes"); q = new ArrayDeque(); } if (uI == 2) { //q turns into a list //System.out.println("no"); q = new ListDeque(); } Integer x = 3; q.enqueue(x); x = -8; q.enqueue(x); x = 15; q.enqueue(x); x = 0; q.enqueue(x); x = -4; q.enqueue(x); System.out.println(q); sc.close(); } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!