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
What settings are available in the Properties dialog box of a message? Check all that apply.
Reptile [31]

Answer:

A,D,E,F

Explanation:

edg2021

8 0
3 years ago
Read 2 more answers
Write an if-else statement for the following: If user_tickets is less than 5, assign num_tickets with 1. Else, assign num_ticket
KatRina [158]

The if-else statement as based on python 3.8 is given below

if user_tickets < 5:

  num_tickets = 1

else:

  num_tickets = user_tickets

Note that if this code is to work properly, a person need to first declare user_tickets before the if-else statements.

<h3>What is this if statement?</h3>

The if/else statement is known to be that which carry out a block of code if a given condition is true.

Note that If the condition is false, a given  or another block of code iis one that can be executed.

Learn more about if-else statements from

brainly.com/question/18736215

#SPJ1

7 0
2 years ago
Select the correct navigational path to create the function syntax to use the IF function.
Harrizon [31]

Answer:

1. Logical

2.=

3.IF

Explanation:

just did the assignment

3 0
4 years ago
Read 2 more answers
An interactive online representation of geospatial data, which can be accesses via a Web browser is a(an): a. Web Application b.
Mashcka [7]

Answer: Web Map

Explanation:

7 0
2 years ago
What does a code of conduct include?
mariarad [96]
The answer is a set of rules for behavior when using the internet 
For example online bullying defies the code of conduct. 
3 0
3 years ago
Other questions:
  • Windows OS and Mac OS are examples of which type of operating systems?
    5·1 answer
  • The programs in a computer are called
    7·1 answer
  • Which of the following statements is false? a. As of Java SE 8, any interface containing only one method is known as a functiona
    6·1 answer
  • Dividing a hard drive into multiple sections is known as partitioning
    5·1 answer
  • Because all the IEEE WLAN features are isolated in the PHY and ____________ layers, practically any LAN application will run on
    11·1 answer
  • The part of the screen where you see the results of your code is called the Editor.
    15·2 answers
  • Order the steps to add a recommended chart in excel.
    5·2 answers
  • How is video compression accomplished?
    14·1 answer
  • Which IP QoS mechanism involves prioritizing traffic? Group of answer choices IntServ RSVP COPS DiffServ None of the above
    14·1 answer
  • Hi, I am from India. Our brainly platform isn't so good, many of 'em keep spamming questions that I ask. US platform seems much
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!