-
/*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
-
Unlocking True Innovation in the Age of Artificial Intelligence Artificial Intelligence is no longer just a futuristic buzzword — it'...
-
Explanation: x is a string: x = "clcoding" When you multiply a string by an integer: x * 0 It repeats the string 0 times...
-
Master Data Science with Python: Exploring Coursera's "Python for Applied Data Science AI" Python has become a cornerstone f...
-
Explanation: 🔹 for i in range(3): This means the loop will run with: i = 0 , 1 , 2 🔹 print(i) Each value of i is printed: 0 1 2 🔹 els...
-
Exploring Coursera's Machine Learning Specialization: A Comprehensive Guide Machine learning (ML) has become one of the most in-demand...
-
Step-by-Step Execution: Function Definition def gen (): yield 10 This defines a generator function . The keyword yield makes...
-
A Deep Dive into HarvardX's CS50 Introduction to Artificial Intelligence with Python Introduction Artificial Intelligence (AI) is tran...
-
Step-by-Step Explanation: ✅ Outer Loop: for i in range ( 2 ): This means i will take values: 0, 1 (range(2) gives [0, 1]) ✅ Inner Loop:...
-
Step-by-Step Explanation: Initialize x = 5 Condition: x in range(10) range(10) means numbers from 0 to 9. x must be one of them...
-
Step-by-step Explanation: Original list: x = [ 1 , 2 , 3 ] What is x[::-1] ? This is list slicing with a step of -1 . It mean...
Categories
100 Python Programs for Beginner
(118)
AI
(52)
Android
(24)
AngularJS
(1)
Api
(2)
Assembly Language
(2)
aws
(19)
Azure
(8)
BI
(10)
book
(4)
Books
(213)
C
(77)
C#
(12)
C++
(83)
Course
(67)
Coursera
(270)
Cybersecurity
(26)
Data Analysis
(11)
Data Analytics
(6)
data management
(13)
Data Science
(162)
Data Strucures
(9)
Deep Learning
(23)
Django
(16)
Downloads
(3)
edx
(12)
Engineering
(15)
Euron
(29)
Events
(6)
Excel
(13)
Factorial
(1)
Finance
(6)
flask
(3)
flutter
(1)
FPL
(17)
Generative AI
(17)
Google
(39)
Hadoop
(3)
HTML Quiz
(1)
HTML&CSS
(47)
IBM
(34)
IoT
(2)
IS
(25)
Java
(94)
Java quiz
(1)
Leet Code
(4)
Machine Learning
(97)
Meta
(22)
MICHIGAN
(5)
microsoft
(8)
Nvidia
(4)
p
(1)
Pandas
(4)
PHP
(20)
Projects
(29)
pyth
(1)
Python
(1109)
Python Coding Challenge
(556)
Python Quiz
(183)
Python Tips
(5)
Questions
(2)
R
(71)
React
(6)
Scripting
(3)
security
(3)
Selenium Webdriver
(4)
Software
(18)
SQL
(44)
UX Research
(1)
web application
(11)
Web development
(4)
web scraping
(2)
0 Comments:
Post a Comment