Write Java Source code: Reverse String in Java Programming
Sample Output:
Enter a word: arif
The reverse word is: fira
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| //Java source code on how to print a string backward using recursion //java class public class StringBackward { public static void reverseString(String word, int size) { if (size== 0 ) { return ; } else { System.out.print(word.charAt(size- 1 )); reverseString(word, size- 1 ); } } } //main class import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); String word; System.out.print( "Enter a word: " ); word = input.next(); StringBackward access = new StringBackward(); System.out.print( "The reverse word is: " ); access.reverseString(word, word.length()); System.out.println(); } } |
This comment has been removed by the author.
ReplyDeleteMohammad Ashraful Hasan Sobuj
ReplyDeleteMy Batch- 46th
My Department :CSE
My ID 201420656
public class StringSetward
{
public static void unsetString(String word, int size)
{
if(size==0)
{
return;
}
else
{
System.out.print(word.charAt(size-1));
unsetString(word, size-1);
}
}
}
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String word;
System.out.print("Enter a word: ");
word = input.next();
StringSetward access = new StringSetward();
System.out.print("The unset word is: ");
access.unsetString(word, word.length());
System.out.println();
}
}
sultana razia khan
ReplyDeleteMy Batch- 46th
My Department :CSE
My ID 201420715
public class Stringbackward
{
public static void unreseString(String word, int size)
{
if(size==0)
{
return;
}
else
{
System.out.print(word.charAt(size-1));
unreseString(word, size-1);
}
}
}
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String word;
System.out.print("Enter a word: ");
word = input.next();
Stringbackward access = new Stringbackward();
System.out.print("The unrese word is: ");
access.unreseString(word, word.length());
System.out.println();
}
}
Sharmin Akter
ReplyDeleteMy Batch- 46th
My Department :CSE
My ID 201420769
public class StringSetward
{
public static void unsetString(String word, int size)
{
if(size==0)
{
return;
}
else
{
System.out.print(word.charAt(size-1));
unsetString(word, size-1);
}
}
}
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String word;
System.out.print("Enter a word: ");
word = input.next();
StringSetward access = new StringSetward();
System.out.print("The unset word is: ");
access.unsetString(word, word.length());
System.out.println();
}
}
MD: Rashed Prodhania (Jewel)
ReplyDeleteID: 201420763
Batch : 46th
public class StringBackward
{
public static void reverseString(String word, int size)
{
if(size==0)
{
return;
}
else
{
System.out.print(word.charAt(size-1));
reverseString(word, size-1);
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String word;
System.out.print("Enter a word: ");
word = input.next();
StringBackward access = new StringBackward();
System.out.print("The reverse word is: ");
access.reverseString(word, word.length());
System.out.println();
}
}
StringBackward access = new StringBackward();
ReplyDeleteCan anyone explain the work of access following this line plz?
This comment has been removed by the author.
ReplyDeleteID-201420406
ReplyDeleteBatch-46th
public class Stringbackward
{
public static void unreseString(String word, int size)
{
if(size==0)
{
return;
}
else
{
System.out.print(word.charAt(size-1));
unreseString(word, size-1);
}
}
}
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String word;
System.out.print("Enter a word: ");
word = input.next();
Stringbackward access = new Stringbackward();
System.out.print("The unrese word is: ");
access.unreseString(word, word.length());
System.out.println();
}
}
Name : Jalis Mahmud
ReplyDeleteID :201420762
Batch : 46th
public class stringsetward
{
public static void unreseString(String word, int size)
{
if(size==0)
{
return;
}
else
{
System.out.print(word.charAt(size-2));
unreseString(word, size-2);
}
}
}
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
String word;
System.out.print("Enter a word: ");
word = input.next();
Stringbackward access = new Stringbackward();
System.out.print("The unrese word is: ");
access.unreseString(word, word.length());
System.out.println();
}
}