public class ReverseThis
static Scanner console = new Scanner(System.in);
public static void main(String args)
String s; //Declare a variable string
String x=""; //Initialize the variable x.
s=console.nextLine();//Accept the input...
System.out.print(s + "\n");//Print the inputted string.
for(int i=s.length()-1;i>=0;i--)//This is how we reverse the inputted string.
char cc = s.charAt(i);
Next time, show to us what you have done so far....So that many will help you...
I do understand since you are still a beginner on this java and i know you are confuse but i am pretty sure that you have ideas how to do this but cannot express in codes...
Note...There are different ways in reversing the Array try to learn and read the java docs that will help you....and lastly if you are really love java don't stop reading books and practicing some exercises from basic to advance...
@NormR1, I do apologize of this. But how can we help the OP (I am reffering to the first time learning in java)...The OP is still getting to know in java,he wants to know what is String and how to manipulate it,Methods and Classes...and i know the OP don't understand yet the API docs in java...
Pseudo code can be a useful tool for explaining algorithms etc, but by doing that you have still deprived the OP of the chance to learn how to solve the logical problem for themselves. Follow Norm's frequent approach of getting the OP to do it by hand on a piece of paper, then generalise what they just did, before going anywhere near a computer.
use toCharArray to read your String into a char array
iterate over them using a simple for loop, after you created a new array of chars of the same size
set the first element of the first array in the last element of the second array
set the second element of the first array in the just not last element of the second array
set the last element of the first array in the first element of the second array
Look at using two arrays: one the source the other the target. Have the index to one point to the source and the index to the other point to the target. Copy an element from where the source index points to where the target index points. Change the indexes to point to the next elements, test if at the end. If not go do it again.
I can create a 'sample program' but that's basically giving you the code. try looking at the pseudo code I gave you, see if you can find the components to use to do that, and decide on the steps, try and write that, and post that here.
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Help! I want to create a java program that finds the highest even integer among the values entered by the user. Stop asking values when a value less than 1 have been entered. If no even integer is entered, display "No Even Integer"