-
/*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
-
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