Soluții

How to Reverse a String in Java

Example 1: Reverse a string word by word using recursion

  1. import java.util.Scanner;
  2. public class ReverseStringExample1
  3. {
  4. public static void main(String[] args)
  5. {
  6. String str;
  7. System.out.println(“Enter a string: “);
  8. Scanner scanner = new Scanner(System.in);
  9. str = scanner.nextLine();
  10. scanner.close();                                //closes the input stream
  11. String reversed = reverseString(str);
  12. System.out.println(“The reversed string is: “ + reversed);
  13. }
  14. public static String reverseString(String s)
  15. {
  16. if (s.isEmpty())                            //checks the string if empty
  17. return s;
  18. return reverseString(s.substring(1)) + s.charAt(0);                     //recursively called function
  19. }
  20. }

Output:

How to Reverse a String in Java Word by Word

[mai mult...]

How to Unhide All Rows in Excel

Unhiding all the rows in a Microsoft Excel spreadsheet is as easy as pressing a keyboard shortcut or using a button on the ribbon.

First, select your entire worksheet using Ctrl+A (Windows) or Command+A (Mac). Press Ctrl+Shift+9, right-click a cell, and choose “Unhide,” or select Format > Hide & Unhide > Unhide Rows from the ribbon at the top to unhide all rows.

[mai mult...]