1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
goldenfox [79]
2 years ago
13

What is the problem, if any, with the following code?The desired output is [3,19].

Computers and Technology
1 answer:
vfiekz [6]2 years ago
8 0

Answer: You need a temporary variable to hold the value 3

Explanation:

So, aList[0] is 3 and aList[1] is 19, if it will be as it is you litteraly say to the compiler to change aList[0] to aList[1]  at this moment aList[0] is 19 and aList[1] also is 19 and if you try to change aList[1] to aList[0]  it will not change its value because they are the same.

You need temp variable to keep one of the values.

You might be interested in
I want to discard my old computer and securely erase the data from my hard drive.
FrozenT [24]
Wipe off the hard drive with a software eraser but it won't be quick and won't work on defective disks
3 0
3 years ago
Previous
KonstantinChe [14]

Answer: Internet service provider

Explanation:

5 0
3 years ago
________is one of the most popular payment gateways founded in in December 1998​
iren2701 [21]

paypel is the most popular

6 0
3 years ago
Now that the classList Array has been implemented, we need to create methods to access the list items.
natima [27]

The following code will be applied to Create the following static methods for the Student class

<u>Explanation:</u>

/* Note: Array index starts from 0 in java so ,, user ask for 1 index then the position will be i-1 , below program is based on this concept if you dont want this way just remove -1 from classList.get(i-1).getName(); ,and classList.add(i-1,student); */

/* ClassListTester.java */

public class ClassListTester

{

public static void main(String[] args)

{

//You don't need to change anything here, but feel free to add more Students!

Student alan = new Student("Alan", 11);

Student kevin = new Student("Kevin", 10);

Student annie = new Student("Annie", 12);

System.out.println(Student.printClassList());

System.out.println(Student.getLastStudent());

System.out.println(Student.getStudent(1));

Student.addStudent(2, new Student("Trevor", 12));

System.out.println(Student.printClassList());

System.out.println(Student.getClassSize());

}

}

/* Student.java */

import java.util.ArrayList;

public class Student

{

private String name;

private int grade;

//Implement classList here:

private static ArrayList<Student> classList = new ArrayList<Student>();

public Student(String name, int grade)

{

this.name = name;

this.grade = grade;

classList.add(this);

}

public String getName()

{

return this.name;

}

//Add the static methods here:

public static String printClassList()

{

String names = "";

for(Student name: classList)

{

names+= name.getName() + "\n";

}

return "Student Class List:\n" + names;

}  

public static String getLastStudent() {

// index run from 0 so last student will be size -1

return classList.get(classList.size()-1).getName();

}

public static String getStudent(int i) {

// array starts from 0 so i-1 will be the student

return classList.get(i-1).getName();

}

public static void addStudent(int i, Student student) {

// array starts from 0 so, we add at i-1 position

classList.add(i-1,student);

// remove extra student

classList.remove(classList.size()-1);

}  

public static int getClassSize() {

return classList.size();

}

}

7 0
3 years ago
What is one purpose of an algorithm
adelina 88 [10]

Answer:

Algorithms is formula for solving a problem. It is helpful because it specifically give instructions detail to computer to what a computer should perform a specific task.

For e.g. calculating report cards.

4 0
3 years ago
Other questions:
  • Which of the following illustrates an example of a Boolean data type?
    15·1 answer
  • Number 20, can anyone help?
    11·1 answer
  • The mathematical constant Pi is an irrational number with value approximately 3.1415928... The precise value of this constant ca
    12·1 answer
  • PLEASE HELP ME ANSWER AS MUCH AS YOU CAN I ONLY HAVE 3 POINTS LEFT AND IM TIMED. PLEASE TELL ME THE NUMBER AND LETTER. THANK YOU
    5·1 answer
  • Pick the simplest line of code to test if the word "BASIC" is stored in the variable text1.
    12·1 answer
  • Which magazine introduced the first microcomputer kit for the mits altair in its january 1975 issue?
    8·1 answer
  • 4. Select the correct answer.
    9·1 answer
  • Describe a cellular network, its principle<br> components and how it works.
    7·1 answer
  • Heyyyyyy who likes anime​
    12·2 answers
  • I NEED HELP, DO ASAP <br> Why do you have to adjust toys for different ages?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!