SlideShare a Scribd company logo
1 of 2
how do I create an array in java using a for loop?
Solution
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) {
// your code goes here
int[] nums = new int[10];
// Fill it with numbers using a for-loop
for (int i = 0; i < nums.length; i++){
nums[i] = i + 1;
}
//print array
for (int i = 0; i < nums.length; i++) {
System.out.println(nums[i] + " ");
}
}
}

More Related Content

More from hjeffrey

How is the nature of 21st century communication changing- How is the n.docx
How is the nature of 21st century communication changing- How is the n.docxHow is the nature of 21st century communication changing- How is the n.docx
How is the nature of 21st century communication changing- How is the n.docxhjeffrey
 
How did the enclosures law fuel the Industrial Revolution in Great Bri.docx
How did the enclosures law fuel the Industrial Revolution in Great Bri.docxHow did the enclosures law fuel the Industrial Revolution in Great Bri.docx
How did the enclosures law fuel the Industrial Revolution in Great Bri.docxhjeffrey
 
How do short-term and long-term orientation relate to corporate profit.docx
How do short-term and long-term orientation relate to corporate profit.docxHow do short-term and long-term orientation relate to corporate profit.docx
How do short-term and long-term orientation relate to corporate profit.docxhjeffrey
 
How does the object-oriented view of component-level design differ fro.docx
How does the object-oriented view of component-level design differ fro.docxHow does the object-oriented view of component-level design differ fro.docx
How does the object-oriented view of component-level design differ fro.docxhjeffrey
 
How do the physical features of mainland Southeast Asia compare and co.docx
How do the physical features of mainland Southeast Asia compare and co.docxHow do the physical features of mainland Southeast Asia compare and co.docx
How do the physical features of mainland Southeast Asia compare and co.docxhjeffrey
 
How do many companies structure the internal audit group-'s reporting.docx
How do many companies structure the internal audit group-'s reporting.docxHow do many companies structure the internal audit group-'s reporting.docx
How do many companies structure the internal audit group-'s reporting.docxhjeffrey
 
How do semaphore relate to Petri Nets in detail-Solutionpetri nets- i.docx
How do semaphore relate to Petri Nets in detail-Solutionpetri nets-  i.docxHow do semaphore relate to Petri Nets in detail-Solutionpetri nets-  i.docx
How do semaphore relate to Petri Nets in detail-Solutionpetri nets- i.docxhjeffrey
 
How do you show charging by induction using a comb- or another plastic.docx
How do you show charging by induction using a comb- or another plastic.docxHow do you show charging by induction using a comb- or another plastic.docx
How do you show charging by induction using a comb- or another plastic.docxhjeffrey
 
How do taxes impact your accumulation-SolutionThere are three asset it.docx
How do taxes impact your accumulation-SolutionThere are three asset it.docxHow do taxes impact your accumulation-SolutionThere are three asset it.docx
How do taxes impact your accumulation-SolutionThere are three asset it.docxhjeffrey
 
How does sucrose and lactose react to Bial-'s test- How does sucrose.docx
How does sucrose and lactose react to Bial-'s test-  How does sucrose.docxHow does sucrose and lactose react to Bial-'s test-  How does sucrose.docx
How does sucrose and lactose react to Bial-'s test- How does sucrose.docxhjeffrey
 
How did the DI change in 2013SolutionCompletelly Discussion on world c.docx
How did the DI change in 2013SolutionCompletelly Discussion on world c.docxHow did the DI change in 2013SolutionCompletelly Discussion on world c.docx
How did the DI change in 2013SolutionCompletelly Discussion on world c.docxhjeffrey
 
How do you write dissociation equations for equilibrium and how do you.docx
How do you write dissociation equations for equilibrium and how do you.docxHow do you write dissociation equations for equilibrium and how do you.docx
How do you write dissociation equations for equilibrium and how do you.docxhjeffrey
 
how can you use pH to separate Nil) ions from Hg(I) ions- The solubili.docx
how can you use pH to separate Nil) ions from Hg(I) ions- The solubili.docxhow can you use pH to separate Nil) ions from Hg(I) ions- The solubili.docx
how can you use pH to separate Nil) ions from Hg(I) ions- The solubili.docxhjeffrey
 
How can you tell that a reaction happened in the double-displacement r.docx
How can you tell that a reaction happened in the double-displacement r.docxHow can you tell that a reaction happened in the double-displacement r.docx
How can you tell that a reaction happened in the double-displacement r.docxhjeffrey
 
How many of these symmetry elements does this complex have- E C2 -v -h.docx
How many of these symmetry elements does this complex have- E C2 -v -h.docxHow many of these symmetry elements does this complex have- E C2 -v -h.docx
How many of these symmetry elements does this complex have- E C2 -v -h.docxhjeffrey
 
How can you identifiy a DNS frame in wired Ethernent- 1- Is it broadca.docx
How can you identifiy a DNS frame in wired Ethernent- 1- Is it broadca.docxHow can you identifiy a DNS frame in wired Ethernent- 1- Is it broadca.docx
How can you identifiy a DNS frame in wired Ethernent- 1- Is it broadca.docxhjeffrey
 
How would you explain to an intelligent but non-scientifically-educate.docx
How would you explain to an intelligent but non-scientifically-educate.docxHow would you explain to an intelligent but non-scientifically-educate.docx
How would you explain to an intelligent but non-scientifically-educate.docxhjeffrey
 
How can you tell what kind of primary atomic bonding is present by not.docx
How can you tell what kind of primary atomic bonding is present by not.docxHow can you tell what kind of primary atomic bonding is present by not.docx
How can you tell what kind of primary atomic bonding is present by not.docxhjeffrey
 
How to separate the solution of ethanol- iodine- and LiNO3 How to sep.docx
How to separate the solution of ethanol- iodine- and LiNO3  How to sep.docxHow to separate the solution of ethanol- iodine- and LiNO3  How to sep.docx
How to separate the solution of ethanol- iodine- and LiNO3 How to sep.docxhjeffrey
 
How would one determine the criteria to rank capital budgeting decisio.docx
How would one determine the criteria to rank capital budgeting decisio.docxHow would one determine the criteria to rank capital budgeting decisio.docx
How would one determine the criteria to rank capital budgeting decisio.docxhjeffrey
 

More from hjeffrey (20)

How is the nature of 21st century communication changing- How is the n.docx
How is the nature of 21st century communication changing- How is the n.docxHow is the nature of 21st century communication changing- How is the n.docx
How is the nature of 21st century communication changing- How is the n.docx
 
How did the enclosures law fuel the Industrial Revolution in Great Bri.docx
How did the enclosures law fuel the Industrial Revolution in Great Bri.docxHow did the enclosures law fuel the Industrial Revolution in Great Bri.docx
How did the enclosures law fuel the Industrial Revolution in Great Bri.docx
 
How do short-term and long-term orientation relate to corporate profit.docx
How do short-term and long-term orientation relate to corporate profit.docxHow do short-term and long-term orientation relate to corporate profit.docx
How do short-term and long-term orientation relate to corporate profit.docx
 
How does the object-oriented view of component-level design differ fro.docx
How does the object-oriented view of component-level design differ fro.docxHow does the object-oriented view of component-level design differ fro.docx
How does the object-oriented view of component-level design differ fro.docx
 
How do the physical features of mainland Southeast Asia compare and co.docx
How do the physical features of mainland Southeast Asia compare and co.docxHow do the physical features of mainland Southeast Asia compare and co.docx
How do the physical features of mainland Southeast Asia compare and co.docx
 
How do many companies structure the internal audit group-'s reporting.docx
How do many companies structure the internal audit group-'s reporting.docxHow do many companies structure the internal audit group-'s reporting.docx
How do many companies structure the internal audit group-'s reporting.docx
 
How do semaphore relate to Petri Nets in detail-Solutionpetri nets- i.docx
How do semaphore relate to Petri Nets in detail-Solutionpetri nets-  i.docxHow do semaphore relate to Petri Nets in detail-Solutionpetri nets-  i.docx
How do semaphore relate to Petri Nets in detail-Solutionpetri nets- i.docx
 
How do you show charging by induction using a comb- or another plastic.docx
How do you show charging by induction using a comb- or another plastic.docxHow do you show charging by induction using a comb- or another plastic.docx
How do you show charging by induction using a comb- or another plastic.docx
 
How do taxes impact your accumulation-SolutionThere are three asset it.docx
How do taxes impact your accumulation-SolutionThere are three asset it.docxHow do taxes impact your accumulation-SolutionThere are three asset it.docx
How do taxes impact your accumulation-SolutionThere are three asset it.docx
 
How does sucrose and lactose react to Bial-'s test- How does sucrose.docx
How does sucrose and lactose react to Bial-'s test-  How does sucrose.docxHow does sucrose and lactose react to Bial-'s test-  How does sucrose.docx
How does sucrose and lactose react to Bial-'s test- How does sucrose.docx
 
How did the DI change in 2013SolutionCompletelly Discussion on world c.docx
How did the DI change in 2013SolutionCompletelly Discussion on world c.docxHow did the DI change in 2013SolutionCompletelly Discussion on world c.docx
How did the DI change in 2013SolutionCompletelly Discussion on world c.docx
 
How do you write dissociation equations for equilibrium and how do you.docx
How do you write dissociation equations for equilibrium and how do you.docxHow do you write dissociation equations for equilibrium and how do you.docx
How do you write dissociation equations for equilibrium and how do you.docx
 
how can you use pH to separate Nil) ions from Hg(I) ions- The solubili.docx
how can you use pH to separate Nil) ions from Hg(I) ions- The solubili.docxhow can you use pH to separate Nil) ions from Hg(I) ions- The solubili.docx
how can you use pH to separate Nil) ions from Hg(I) ions- The solubili.docx
 
How can you tell that a reaction happened in the double-displacement r.docx
How can you tell that a reaction happened in the double-displacement r.docxHow can you tell that a reaction happened in the double-displacement r.docx
How can you tell that a reaction happened in the double-displacement r.docx
 
How many of these symmetry elements does this complex have- E C2 -v -h.docx
How many of these symmetry elements does this complex have- E C2 -v -h.docxHow many of these symmetry elements does this complex have- E C2 -v -h.docx
How many of these symmetry elements does this complex have- E C2 -v -h.docx
 
How can you identifiy a DNS frame in wired Ethernent- 1- Is it broadca.docx
How can you identifiy a DNS frame in wired Ethernent- 1- Is it broadca.docxHow can you identifiy a DNS frame in wired Ethernent- 1- Is it broadca.docx
How can you identifiy a DNS frame in wired Ethernent- 1- Is it broadca.docx
 
How would you explain to an intelligent but non-scientifically-educate.docx
How would you explain to an intelligent but non-scientifically-educate.docxHow would you explain to an intelligent but non-scientifically-educate.docx
How would you explain to an intelligent but non-scientifically-educate.docx
 
How can you tell what kind of primary atomic bonding is present by not.docx
How can you tell what kind of primary atomic bonding is present by not.docxHow can you tell what kind of primary atomic bonding is present by not.docx
How can you tell what kind of primary atomic bonding is present by not.docx
 
How to separate the solution of ethanol- iodine- and LiNO3 How to sep.docx
How to separate the solution of ethanol- iodine- and LiNO3  How to sep.docxHow to separate the solution of ethanol- iodine- and LiNO3  How to sep.docx
How to separate the solution of ethanol- iodine- and LiNO3 How to sep.docx
 
How would one determine the criteria to rank capital budgeting decisio.docx
How would one determine the criteria to rank capital budgeting decisio.docxHow would one determine the criteria to rank capital budgeting decisio.docx
How would one determine the criteria to rank capital budgeting decisio.docx
 

Recently uploaded

_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 

Recently uploaded (20)

Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 

how do I create an array in java using a for loop-Solutionimport java-.docx

  • 1. how do I create an array in java using a for loop? Solution import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { public static void main (String[] args) { // your code goes here int[] nums = new int[10]; // Fill it with numbers using a for-loop for (int i = 0; i < nums.length; i++){ nums[i] = i + 1; } //print array for (int i = 0; i < nums.length; i++) { System.out.println(nums[i] + " ");