-
/*Java Reverse String Array ExampleThis Java Reverse String Array example shows how to find sort an array ofString in Java using Arrays and Collections classes.*/
import java.util.Collections;import java.util.List;import java.util.Arrays;
public class ReverseStringArrayExample {
public static void main(String args[]){
//String arrayString[] strDays = new String[]{“Sunday”, “Monday”, “Tuesday”, “Wednesday”};
/** There are basically two methods, one is to use temporary array and* manually loop through the elements of an Array and swap them or to use* Arrays and Collections classes.** This example uses the second approach i.e. without temp variable.**///first create a list from String arrayList<String> list = Arrays.asList(strDays);
//next, reverse the list using Collections.reverse methodCollections.reverse(list);
//next, convert the list back to String arraystrDays = (String[]) list.toArray();
System.out.println(“String array reversed”);
//print the reversed String arrayfor(int i=0; i < strDays.length; i++){System.out.println(strDays[i]);}
}
}
/*Output of above given Java Reverse String Array example would beString array reversedWednesdayTuesdayMondaySunday*/
Friday, 13 April 2018
Popular Posts
-
Explanation of the Code This code demonstrates Python's iterable unpacking feature, specifically using the * operator to collect rema...
-
Explanation If you read through , which defines assignment expressions, you’ll see a section called Exceptional cases, which has an exampl...
-
Python is often hailed as the “Swiss Army knife” of programming languages due to its simplicity, versatility, and powerful capabilities. F...
-
Python has quickly become one of the most popular programming languages worldwide, and for good reason. It's versatile, easy to learn, a...
-
Explanation The code in this quiz is tricky! Here you are modifying the list that the generator wants to use. Here is the key to understan...
-
The Business Analytics Masters program by Euron is an exceptional course tailored to meet the growing demand for professionals who can tra...
-
Explanation Input Lists : a is a list of integers: [1, 2, 3] b is a list of strings: ['x', 'y', 'z'] zip Function...
-
Explanation np.array([1, 2, 3, 4]) : Creates a NumPy array arr with the elements [1, 2, 3, 4]. np.clip(arr, 2, 3) : The np.clip() function...
-
14 Foundational Concepts Every Python Programmer Should Master Python, a versatile and beginner-friendly language, offers a plethora of fe...
Categories
100 Python Programs for Beginner
(96)
AI
(38)
Android
(24)
AngularJS
(1)
Assembly Language
(2)
aws
(17)
Azure
(7)
BI
(10)
book
(4)
Books
(184)
C
(77)
C#
(12)
C++
(83)
Course
(67)
Coursera
(236)
Cybersecurity
(25)
Data Analytics
(2)
data management
(11)
Data Science
(138)
Data Strucures
(8)
Deep Learning
(21)
Django
(14)
Downloads
(3)
edx
(2)
Engineering
(14)
Euron
(22)
Excel
(13)
Factorial
(1)
Finance
(6)
flask
(3)
flutter
(1)
FPL
(17)
Generative AI
(5)
Google
(34)
Hadoop
(3)
HTML Quiz
(1)
HTML&CSS
(47)
IBM
(30)
IoT
(1)
IS
(25)
Java
(93)
Java quiz
(1)
Leet Code
(4)
Machine Learning
(67)
Meta
(22)
MICHIGAN
(5)
microsoft
(4)
Nvidia
(4)
Pandas
(4)
PHP
(20)
Projects
(29)
pyth
(1)
Python
(969)
Python Coding Challenge
(415)
Python Quiz
(62)
Python Tips
(3)
Questions
(2)
R
(70)
React
(6)
Scripting
(1)
security
(3)
Selenium Webdriver
(4)
Software
(17)
SQL
(42)
UX Research
(1)
web application
(8)
Web development
(4)
web scraping
(2)
0 Comments:
Post a Comment