
Asked in Dassault Systemes and 14 others
Write a Java program to reverse a string without using predefined methods.

AnswerBot
10mo
Java program to reverse a string without using predefined methods.
Create a char array from the input string.
Use two pointers, one at the start and one at the end, to swap characters.
Continue swapping ...read more
jone selas
1y
string originalString = "test"; string reverseString = string.Empty; foreach (char c in originalString) { reverseString = c + reverseString; } return reverseString;
Mukesh Ningadali
3y
import java.util.Scanner;
public class ReverseStringByScanner {
public static void main(String[] args) {
String str;
Scanner scanner=new Scanner(System.in);
System.out.print("Enter a Str...read more
Anonymous
3y
class ReverseString
{
public static void main(String[] args)
{
String str = "Hello team";
String reverseString = "";
for(int i = str.length() - 1 ; i>=0 ; i--)
{
reverseString += str.charAt(i);...read more
Sonu Dixit
6y
Sir nokri dedo
Add answer anonymously...
Interview Questions from Popular Companies

3.7
• 8.8k Interviews

4.0
• 5.5k Interviews

3.5
• 4.2k Interviews

3.6
• 8k Interviews

3.7
• 6k Interviews

3.7
• 6.2k Interviews

3.5
• 4.2k Interviews

3.7
• 5.1k Interviews
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

