-
/*Java ArrayList to String Array ExampleThis Java ArrayList to String Array example shows how to convert ArrayList to String arrayin Java.*/
import java.util.ArrayList;import java.util.Arrays;
public class ArrayListToStringArrayExample {
public static void main(String args[]){
//ArrayList containing string objectsArrayList<String> aListDays = new ArrayList<String>();aListDays.add(“Sunday”);aListDays.add(“Monday”);aListDays.add(“Tuesday”);
/** To convert ArrayList containing String elements to String array, use* Object[] toArray() method of ArrayList class.** Please note that toArray method returns Object array, not String array.*///First Step: convert ArrayList to an Object array.Object[] objDays = aListDays.toArray();
//Second Step: convert Object array to String arrayString[] strDays = Arrays.copyOf(objDays, objDays.length, String[].class);
System.out.println(“ArrayList converted to String array”);
//print elements of String arrayfor(int i=0; i < strDays.length; i++){System.out.println(strDays[i]);}}}
/*Output of above given ArrayList to String Array example would beArrayList converted to String arraySundayMondayTuesday*/
Friday, 13 April 2018
Popular Posts
-
Introduction Machine Learning (ML) is one of the most influential technologies in today’s digital world. From recommendation systems and v...
-
If you’ve ever wanted to learn how to code, Python is one of the best languages to start with. It’s simple, readable, and widely used acr...
-
Machine learning has become one of the most essential skills in technology today. It powers personalized recommendations, fraud detection ...
-
Artificial Intelligence (AI) is no longer confined to research labs — it’s now central to business innovation, technology strategy, and ev...
-
Explanation: a = 257 An integer object with value 257 is created in memory. Variable a is assigned to reference this object. Since 257 is...
-
Deep learning has rapidly emerged as a driving force behind many of the most impressive advancements in artificial intelligence. From voic...
-
Computer vision — the field that enables machines to see , interpret, and act on visual data — is one of the most exciting areas of artifi...
-
Time series data is everywhere — from stock prices and weather patterns to sales forecasts and sensor data. Understanding how to analyze a...
-
In modern software development, automation isn’t a luxury — it’s a necessity. DevOps practices aim to accelerate delivery while maintainin...
-
Explanation: 1. Creating a Tuple a = (1, 2, 3) This line creates a tuple named a. A tuple is an ordered collection of elements. Tuples are...
Categories
100 Python Programs for Beginner
(119)
AI
(213)
Android
(25)
AngularJS
(1)
Api
(7)
Assembly Language
(2)
aws
(28)
Azure
(9)
BI
(10)
Books
(262)
Bootcamp
(1)
C
(78)
C#
(12)
C++
(83)
Course
(86)
Coursera
(300)
Cybersecurity
(29)
data
(2)
Data Analysis
(26)
Data Analytics
(20)
data management
(15)
Data Science
(310)
Data Strucures
(16)
Deep Learning
(128)
Django
(16)
Downloads
(3)
edx
(21)
Engineering
(15)
Euron
(30)
Events
(7)
Excel
(18)
Finance
(10)
flask
(3)
flutter
(1)
FPL
(17)
Generative AI
(65)
Git
(10)
Google
(50)
Hadoop
(3)
HTML Quiz
(1)
HTML&CSS
(48)
IBM
(41)
IoT
(3)
IS
(25)
Java
(99)
Leet Code
(4)
Machine Learning
(255)
Meta
(24)
MICHIGAN
(5)
microsoft
(11)
Nvidia
(8)
Pandas
(13)
PHP
(20)
Projects
(32)
Python
(1260)
Python Coding Challenge
(1054)
Python Mistakes
(50)
Python Quiz
(432)
Python Tips
(5)
Questions
(3)
R
(72)
React
(7)
Scripting
(3)
security
(4)
Selenium Webdriver
(4)
Software
(19)
SQL
(46)
Udemy
(17)
UX Research
(1)
web application
(11)
Web development
(8)
web scraping
(3)

0 Comments:
Post a Comment