SlideShare a Scribd company logo
1 of 2
Download to read offline
Create the Java function to receive an ArrayList object. The function will count all of the single-
digit positive numbers in the array and return that total.
Solution
CountSingleDigit.java
import java.util.ArrayList;
public class CountSingleDigit {
public static void main(String[] args) {
ArrayList list = new ArrayList();
list.add(11);
list.add(112);
list.add(1);
list.add(1441);
list.add(1155);
list.add(6);
list.add(81);
list.add(8);
list.add(3);
list.add(111111);
int count = getSinglDigitCount(list);
System.out.println("Count = "+count);
}
public static int getSinglDigitCount(ArrayList list){
int count = 0;
for(int i=0; i=0 && list.get(i) <= 9){
count++;
}
}
return count;
}
}
Output:
Count = 4

More Related Content

More from jaronkyleigh59760

Why do ion channels not function like open poresWhat is membrane .pdf
Why do ion channels not function like open poresWhat is membrane .pdfWhy do ion channels not function like open poresWhat is membrane .pdf
Why do ion channels not function like open poresWhat is membrane .pdf
jaronkyleigh59760
 
what are the changes to IMC strategy a company faces in light of the.pdf
what are the changes to IMC strategy a company faces in light of the.pdfwhat are the changes to IMC strategy a company faces in light of the.pdf
what are the changes to IMC strategy a company faces in light of the.pdf
jaronkyleigh59760
 
What are homologous traits Similar traits in different organisms bas.pdf
What are homologous traits Similar traits in different organisms bas.pdfWhat are homologous traits Similar traits in different organisms bas.pdf
What are homologous traits Similar traits in different organisms bas.pdf
jaronkyleigh59760
 
Item 1In the case below, the original source material is given alo.pdf
Item 1In the case below, the original source material is given alo.pdfItem 1In the case below, the original source material is given alo.pdf
Item 1In the case below, the original source material is given alo.pdf
jaronkyleigh59760
 
In your opinion, what is the purpose of a funeral What function doe.pdf
In your opinion, what is the purpose of a funeral What function doe.pdfIn your opinion, what is the purpose of a funeral What function doe.pdf
In your opinion, what is the purpose of a funeral What function doe.pdf
jaronkyleigh59760
 
In two paragraphs, how it should be the Academic plan for an engineer.pdf
In two paragraphs, how it should be the Academic plan for an engineer.pdfIn two paragraphs, how it should be the Academic plan for an engineer.pdf
In two paragraphs, how it should be the Academic plan for an engineer.pdf
jaronkyleigh59760
 
in natural selection, explain what is a sexual selection, neutral va.pdf
in natural selection, explain what is a sexual selection, neutral va.pdfin natural selection, explain what is a sexual selection, neutral va.pdf
in natural selection, explain what is a sexual selection, neutral va.pdf
jaronkyleigh59760
 
In a 2 to 3 page paper, research and discuss the dilemmas we now fac.pdf
In a 2 to 3 page paper, research and discuss the dilemmas we now fac.pdfIn a 2 to 3 page paper, research and discuss the dilemmas we now fac.pdf
In a 2 to 3 page paper, research and discuss the dilemmas we now fac.pdf
jaronkyleigh59760
 

More from jaronkyleigh59760 (20)

Why do ion channels not function like open poresWhat is membrane .pdf
Why do ion channels not function like open poresWhat is membrane .pdfWhy do ion channels not function like open poresWhat is membrane .pdf
Why do ion channels not function like open poresWhat is membrane .pdf
 
Which of the following is not an organic molecule C_12 H_9 SO_3.pdf
Which of the following is not an organic molecule  C_12 H_9 SO_3.pdfWhich of the following is not an organic molecule  C_12 H_9 SO_3.pdf
Which of the following is not an organic molecule C_12 H_9 SO_3.pdf
 
1. The process of an internal employee or outside consultant reviewi.pdf
1. The process of an internal employee or outside consultant reviewi.pdf1. The process of an internal employee or outside consultant reviewi.pdf
1. The process of an internal employee or outside consultant reviewi.pdf
 
what does the pi signify in statistics I have a Ho and Ha. pi(i.pdf
what does the pi signify in statistics I have a Ho and Ha. pi(i.pdfwhat does the pi signify in statistics I have a Ho and Ha. pi(i.pdf
what does the pi signify in statistics I have a Ho and Ha. pi(i.pdf
 
what are the changes to IMC strategy a company faces in light of the.pdf
what are the changes to IMC strategy a company faces in light of the.pdfwhat are the changes to IMC strategy a company faces in light of the.pdf
what are the changes to IMC strategy a company faces in light of the.pdf
 
What factors did the researchers determine prevented the Soay sheep i.pdf
What factors did the researchers determine prevented the Soay sheep i.pdfWhat factors did the researchers determine prevented the Soay sheep i.pdf
What factors did the researchers determine prevented the Soay sheep i.pdf
 
What are homologous traits Similar traits in different organisms bas.pdf
What are homologous traits Similar traits in different organisms bas.pdfWhat are homologous traits Similar traits in different organisms bas.pdf
What are homologous traits Similar traits in different organisms bas.pdf
 
There are 102 people consisting of 51 married couples in a room. Ass.pdf
There are 102 people consisting of 51 married couples in a room. Ass.pdfThere are 102 people consisting of 51 married couples in a room. Ass.pdf
There are 102 people consisting of 51 married couples in a room. Ass.pdf
 
List the necessary steps for the Abiotic origin of life theoryS.pdf
List the necessary steps for the Abiotic origin of life theoryS.pdfList the necessary steps for the Abiotic origin of life theoryS.pdf
List the necessary steps for the Abiotic origin of life theoryS.pdf
 
ldentify the correct statement(s) regarding threats to independence .pdf
ldentify the correct statement(s) regarding threats to independence .pdfldentify the correct statement(s) regarding threats to independence .pdf
ldentify the correct statement(s) regarding threats to independence .pdf
 
Item 1In the case below, the original source material is given alo.pdf
Item 1In the case below, the original source material is given alo.pdfItem 1In the case below, the original source material is given alo.pdf
Item 1In the case below, the original source material is given alo.pdf
 
In your opinion, what is the purpose of a funeral What function doe.pdf
In your opinion, what is the purpose of a funeral What function doe.pdfIn your opinion, what is the purpose of a funeral What function doe.pdf
In your opinion, what is the purpose of a funeral What function doe.pdf
 
In two paragraphs, how it should be the Academic plan for an engineer.pdf
In two paragraphs, how it should be the Academic plan for an engineer.pdfIn two paragraphs, how it should be the Academic plan for an engineer.pdf
In two paragraphs, how it should be the Academic plan for an engineer.pdf
 
in natural selection, explain what is a sexual selection, neutral va.pdf
in natural selection, explain what is a sexual selection, neutral va.pdfin natural selection, explain what is a sexual selection, neutral va.pdf
in natural selection, explain what is a sexual selection, neutral va.pdf
 
In a 2 to 3 page paper, research and discuss the dilemmas we now fac.pdf
In a 2 to 3 page paper, research and discuss the dilemmas we now fac.pdfIn a 2 to 3 page paper, research and discuss the dilemmas we now fac.pdf
In a 2 to 3 page paper, research and discuss the dilemmas we now fac.pdf
 
Compare and contrast the traits and growth patterns ofopportunisti.pdf
Compare and contrast the traits and growth patterns ofopportunisti.pdfCompare and contrast the traits and growth patterns ofopportunisti.pdf
Compare and contrast the traits and growth patterns ofopportunisti.pdf
 
How heat is gained by a sustance inside a metal box by radiation of .pdf
How heat is gained by a sustance inside a metal box by radiation of .pdfHow heat is gained by a sustance inside a metal box by radiation of .pdf
How heat is gained by a sustance inside a metal box by radiation of .pdf
 
Help me with python! (3 problems)This is a recursion section! Plea.pdf
Help me with python! (3 problems)This is a recursion section! Plea.pdfHelp me with python! (3 problems)This is a recursion section! Plea.pdf
Help me with python! (3 problems)This is a recursion section! Plea.pdf
 
Explain how to distinguish between these arthropod spiders, inse.pdf
Explain how to distinguish between these arthropod spiders, inse.pdfExplain how to distinguish between these arthropod spiders, inse.pdf
Explain how to distinguish between these arthropod spiders, inse.pdf
 
Discuss the difference between Bacillus and bacilli, and the differe.pdf
Discuss the difference between Bacillus and bacilli, and the differe.pdfDiscuss the difference between Bacillus and bacilli, and the differe.pdf
Discuss the difference between Bacillus and bacilli, and the differe.pdf
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 

Recently uploaded (20)

Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
What is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptxWhat is 3 Way Matching Process in Odoo 17.pptx
What is 3 Way Matching Process in Odoo 17.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Play hard learn harder: The Serious Business of Play
Play hard learn harder:  The Serious Business of PlayPlay hard learn harder:  The Serious Business of Play
Play hard learn harder: The Serious Business of Play
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 

Create the Java function to receive an ArrayList object. The functio.pdf

  • 1. Create the Java function to receive an ArrayList object. The function will count all of the single- digit positive numbers in the array and return that total. Solution CountSingleDigit.java import java.util.ArrayList; public class CountSingleDigit { public static void main(String[] args) { ArrayList list = new ArrayList(); list.add(11); list.add(112); list.add(1); list.add(1441); list.add(1155); list.add(6); list.add(81); list.add(8); list.add(3); list.add(111111); int count = getSinglDigitCount(list); System.out.println("Count = "+count); } public static int getSinglDigitCount(ArrayList list){ int count = 0; for(int i=0; i=0 && list.get(i) <= 9){ count++; } } return count; } } Output: