TLAČ REŤAZEC V OPAČNOM PORADÍ, JAVA

Príklady kódu

6
0

N

// Use StringBuilder for non-thread environment, it is faster
String string="whatever";
String reverse = new StringBuilder(string).reverse().toString();
System.out.println(reverse);
2
0

N

// Reverse a string in java without using reverse function
import java.util.Scanner;
public class ReverseWithoutFunction 
{
   public static void main(String[] args) 
   {
      Scanner sc = new Scanner(System.in);
      System.out.println("Please enter a string: ");
      String strInput = sc.nextLine();
      int len = strInput.length();
      String strReverse = "";
      System.out.println("Reverse a string without using reverse function: ");
      for(int a = len - 1; a >= 0; a--)
      {
         strReverse = strReverse + strInput.charAt(a);
      }
      System.out.println(strReverse);
      sc.close();
   }
}
1
0

N

// reverse a string using character array
class ReverseUsingCharacterArray
{
   public static void main(String[] args)
   {
      String str = "HelloWorldJava";
      char[] ch = str.toCharArray();
      for(int a = ch.length - 1; a >= 0; a--)
         System.out.print(ch[a]);
   }
}
0
0

N

Don't use Java, use C#

Podobné stránky

Podobné stránky s príkladmi

V iných jazykoch

Táto stránka je v iných jazykoch

Русский
..................................................................................................................
English
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................