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
Which of the following storage devices allows access to information in a sequential mode?
katrin [286]
It is either hard drive or solid state drive
4 0
3 years ago
Read 2 more answers
Hi, please help me, solution.​
loris [4]

Answer:

error: incompatible types

Explanation:

Given

The attached code

Required

The output

Variable "a" is declared as float

While p is declared as a pointer to an integer variable

An error of incompatible types will be returned on line 3, <em>int *p = a;</em>

Because the variables are not the same.

To assign a to p*, we have to use type casting.

Hence, (b) is correct

5 0
3 years ago
What are the coordinates of point B in the diagram? A. (3.25, -2.5) B. (4, -5) C. (1, 3) D. (2.5, 0)
Pie
Isn't it B because the x is increasing by .75 and y is deceasing by 2.5
8 0
3 years ago
Read 2 more answers
What is the purpose of a Program Epic?
tigry1 [53]
Maybe try google?gvvv
7 0
3 years ago
Read 2 more answers
Using emails for time-sensitive messages is an example of:
blagie [28]

Answer:time-sensitive email

5 0
3 years ago
Other questions:
  • What do radio telescopes use to gather and focus radio waves?
    14·2 answers
  • Proxy servers and ACLs on network devices are examples of non-security devices with security features, while firewalls and IDS/I
    8·1 answer
  • The labels on the tab buttons on the Driver tab of the Windows Device are Driver Details, Update Driver, Roll Back Driver, Unins
    12·1 answer
  • Be able to list a technology-based company and discuss whether it enjoys sustainable competitive advantage based on the resource
    13·1 answer
  • Describe how asymmetric encryption is used to send a message from User A to User B that assures data confidentiality, authentica
    9·1 answer
  • Which is true about lists and stacks?
    8·1 answer
  • What is the importance of human flourishing to science and technology?​
    8·1 answer
  • A line beginning with a # will be transmitted to the programmer’s social media feed.
    11·2 answers
  • Solve(-8/3)+7/5 please answer​
    5·1 answer
  • Using these Web sites for guidance, write a definition in your own words for five of the terms listed below.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!