Can anyone tell me why this wont compile? Its just like an example that my instr
ID: 3663598 • Letter: C
Question
Can anyone tell me why this wont compile? Its just like an example that my instructor showed us
I need help debugging the rest of it
public class OrderedList
{
private int[] a;
private int b;
OrderedList ()
{
a = new int[10];
}
public void insert (int var)
{
int j = 0;
for (int i= 0; i < b; i++, j++)
if(var < a[i]) break;
for (int i = b - 1; i > j; ) a[i] = a[i--];
a[j]= var;
}
public void print ()
{
for (int i = 1; i < b; i++)
{
if (i%5 ==0) System.out.println();
System.out.print(a[i] + " ");
}
}
}
Explanation / Answer
To debug it you should include the main method as following
public static void main(String[] args) {
OrderList t=new OrderList();
t.insert(11);
t.print();
}
if you dont get it post the question instead of the program
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.