-
/*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
-
This textbook grew out of notes for the ECE143 Programming for Data Analysis class that the author has been teaching at University of Cali...
-
What you'll learn Use SQL commands to filter, sort, & summarize data; manipulate strings, dates, & numerical data from differe...
-
There are 6 modules in this course Cybersecurity affects everyone, including in the delivery of basic products and services. If you or you...
-
In Python, dictionaries are compared based on their keys and corresponding values. When you use the != operator to compare two dictionarie...
-
This Python code defines a function and then calls it with specific arguments. Let's break it down step by step: Function Definition: ...
-
import turtle def draw_ring(color, x, y): turtle.penup() turtle.color(color) turtle.goto(x, y) turtle.pendown() turtle...
-
What you'll learn Develop custom Python scripts to automate cybersecurity tasks. Apply Python to meet objectives through the cybersecu...
-
There are 12 modules in this course Stanford's "Introduction to Statistics" teaches you statistical thinking concepts that a...
-
What you'll learn Create basic visualizations such as line graphs, bar graphs, and pie charts using Excel spreadsheets. Explain the im...
-
What you'll learn Manipulate primitive data types in the R programming language using RStudio or Jupyter Notebooks. Control program fl...
Categories
AI
(28)
Android
(24)
AngularJS
(1)
Assembly Language
(2)
aws
(17)
Azure
(7)
BI
(10)
book
(4)
Books
(121)
C
(77)
C#
(12)
C++
(82)
Course
(66)
Coursera
(184)
Cybersecurity
(24)
data management
(11)
Data Science
(99)
Data Strucures
(7)
Deep Learning
(11)
Django
(6)
Downloads
(3)
edx
(2)
Engineering
(14)
Excel
(13)
Factorial
(1)
Finance
(6)
flutter
(1)
FPL
(17)
Google
(19)
Hadoop
(3)
HTML&CSS
(46)
IBM
(25)
IoT
(1)
IS
(25)
Java
(93)
Leet Code
(4)
Machine Learning
(46)
Meta
(18)
MICHIGAN
(5)
microsoft
(4)
Pandas
(3)
PHP
(20)
Projects
(29)
Python
(793)
Python Coding Challenge
(273)
Questions
(2)
R
(70)
React
(6)
Scripting
(1)
security
(3)
Selenium Webdriver
(2)
Software
(17)
SQL
(41)
UX Research
(1)
web application
(8)
0 Comments:
Post a Comment