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
An advertisement for new headphones lists the cool colors available, the great sound quality, and the fabulous reviews but fails
Mama L [17]

d transfer

ive seen the ad

7 0
3 years ago
Write a program that asks the user to input their first and last names. The first prompt should state:
VikaD [51]

first = input("Please input your first name: ")

last = input("Please input your last name: ")

print(last+", "+first)

I hope this helps!

8 0
2 years ago
Each server on a network that needs to act as a web server needs an application layer software package called a (n) ____________
vovangra [49]
I believe the answer is in the question, web server. although I may be wrong
3 0
3 years ago
In a computer spreadsheet, tool used to construct formulas is called *
zubka84 [21]

Formula bar is the tool used to contrust formula

3 0
3 years ago
There are four ways to create a macro? FALSE OR TRUE
Murljashka [212]

Answer: True

Explanation:

There are actually four ways to create a macro. You would want to use %let.

7 0
2 years ago
Read 2 more answers
Other questions:
  • Using the flowchart below, what value when entered for Y will generate a mathematical error and prevent our flowchart from being
    14·1 answer
  • The _______ has shortcuts to commonly used commands
    8·2 answers
  • PLEASE PLEASE PLEASE HELP!! WILL GIVE A BRAINLIEST IF UR RIGHT!!
    14·1 answer
  • List of most popular entertainment and culture websites
    15·1 answer
  • Anusha wants to use her computer,rather than handwriting the information on her notepad,to analyze her monthly expenses to make
    14·1 answer
  • HELPPPP PLEASE HURRY
    15·1 answer
  • How to format the selected range of cells as u.s currency
    6·1 answer
  • Which lighting technique can often heighten a dramatic story?
    14·1 answer
  • What is the core function of an enterprise platform
    12·2 answers
  • Given three floating-point numbers x, y, and z, output x to the power of y, x to the power of (y to the power of z), the absolut
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!