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]
2 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]2 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
Using numerous computers to inundate and overwhelm the network from numerous launch points is called a(n) ________ attack.
AnnZ [28]
Distributed Denial of Service /<span> </span><span>DDoS</span>
4 0
2 years ago
How many people watch Anime in the world?
iren [92.7K]
3 to 4 billion people.

7 0
3 years ago
Read 2 more answers
To select a number format, you can choose a category in the Number tab in the Format Cells dialog box and then select the number
siniylev [52]

Answer:

1.true

Explanation:

6 0
3 years ago
As a bank employee, you often work from home and remotely access a file server on the bank’s network to correct errors in financ
strojnjashka [21]

Answer:

TACACS+

Explanation:

Terminal Access Controller Access-Control System Plus (TACACS+) is a protocol that provides detailed accounting information and flexible administrative control over the authentication, authorization, and accounting process.

3 0
3 years ago
What happens to an LR if they troll/spam?
Mkey [24]
They have a chance of being blocked
8 0
3 years ago
Other questions:
  • A(n) ____ loop executes a predetermined number of times.
    12·1 answer
  • How is a network printer identified on the network?
    8·1 answer
  • An unwanted 'explosion' of inbox messages is called​
    8·2 answers
  • Trojan Horse is a malicious program and a virus is a program. <br><br> a. True <br> b. False
    6·1 answer
  • Where can you find gradpoint answers
    13·2 answers
  • It is not important to keep financial records since they can all be found online.
    5·2 answers
  • Which of these components is a part of the Central Processing Unit (CPU) of a computer?
    11·2 answers
  • E-mail messages, instant messages (IMs), or text messages sent and/or received within an organization a. are not included on a r
    9·1 answer
  • You are given an integer N, followed by N lines of input (1 &lt;= N &lt;= 100). Each line of input contains one or several words
    8·1 answer
  • Help asap !!!<br>which component of cpu controls the overall operation of computer..​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!