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
Firdavs [7]
3 years ago
12

I have to write this in Java, but i've never even learned it before and i'm completely lost

Computers and Technology
1 answer:
Varvara68 [4.7K]3 years ago
7 0

Answer:

private void printArray(int[] arr){   //0

  System.out.print("[");   //1

  for(int k : arr){   //2

     System.out.print(k + ", ");   //3

  }

  System.out.println("]");   //4

}

Explanation:

This method should get you started. Your teacher may want a different format or a different type of loop. If you haven't learned for loops yet don't use them that'd be suspicious ;)

What I did:

0: This is the method heading with one parameter for the 1D array. If you need to access it in a different class change private to public.

1: This prints the [ with no line break

2: This is an enhanced for loop to iterate through each element in a 1D array. Alternatively, a normal for loop looks like this:

for (int i = 0; i < arr.length; i++)

instead of retrieving the variable with the enhanced for, you'd have to use arr[i] instead of k in this scenario.

3: This prints the value in each pass of the loop along with a comma and a space.

4: This adds the ] with a line break when the loop is completed

Hope this helps you get started :D comment if you need further help

You might be interested in
A loop decision point for an algorithm consists of three features: an initial value, a set of actions to be performed, and a(n)
user100 [1]

Answer:

A test condition

Explanation:

In programming, loops (for, while and do...while) will contain these three components. Consider the for statement below in java/c++/c language

for(int i = 0; i<10; i++) there are three components in there

int i = 0 //The Initial value

i<10 //This is the test condition

i++ // An action performed to change (increment) the value of i

A while statement also has these three components and without the test condition to be checked at each iteration, the code won't compile. The loop only continous as long as the condition remains true.

8 0
4 years ago
How to create table/form libreoffice
Alexxandr [17]

Try using this website to help:

https://help.libreoffice.org/Writer/Inserting_Tables

5 0
4 years ago
A network address is 131.247.160.0/19. The 19 implies that
anyanavicka [17]

Answer:

D. 19 bits are reserved for the network part of IP addresses on the Network

Explanation:

The /19, expresses in the CIDR (Classless Interdomain Routing) notation, how many bits are part of the address mask, which represent the network ID in the IPv4 address.

In this case, we have the first 19 bits set to “1”, which in decimal notation should be written as follows:

255.255.224.0

4 0
4 years ago
To create a microsoft�� powerpoint�� presentation based on an installed template, click the
Levart [38]
Go on to power point and go onto templates and then it will show templates
3 0
4 years ago
Read 2 more answers
What element of the motherboard is responsible for controlling the flow of data, signals, and instructions over the buses on the
Andrej [43]
The answer is A) chipest
6 0
3 years ago
Other questions:
  • Charges of the opposite tend to repel each other.
    9·2 answers
  • Why was the movable type of the printing press such a breakthrough for publishing?
    15·2 answers
  • Standards for all managers ethical responsibilities are covered in a company's
    7·2 answers
  • The Internet has made going global easier than it has ever been, but the promise of "borderless commerce" remains restrained bec
    12·1 answer
  • The base position for your fingers to be placed on a keyboard is called<br> 2 point
    15·2 answers
  • Plz help code practice for python
    11·2 answers
  • You choose Option A for Overdraft Options. What would happen if you had $30 in your checking account and you tried to take out $
    12·1 answer
  • You are considering creating a new operating system to compete with the current operating systems on the market. You must decide
    8·1 answer
  • Is anyone else's pa.dl.et not working??? It says The requested URL / was not found on this server. That’s all we know.
    14·1 answer
  • The Crow’s foot symbol with two vertical parallel lines indicates _____ cardinality.a. (0,N)b. (1,N)c. (1,1)d. (0,1)
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!