function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
please tell me how to write a programme for list using reverse string
lets say List is List<String > TestList = new List<String>{'test1', 'paper'};
for list of reversed strings will be
List<String> newList = new List<String.();
for ( String s : TestList)
{
newList.add(reverse( s));
}
system.debug('======Reversed List======='+newList);
public String reverse( String string ) {
byte[] array = string.getBytes(); byte swap;
for( int i = 0, j = array.length - 1; i < array.length / 2; i++, j-- ) { swap = array[ j ]; array[ j ] = array[ i ]; array[ i ] = swap; }
return new String( array );}
Please mark my answer as solution if it was helpful and give KUDOS.
Hi shasha777,
Please try this one ::
List<String > actualList = new List<String>{'tejpal', 'kumawat'};List<String> reverseList = new List<String>();for ( String s : actualList){ reverseList.add(s.reverse());}system.debug('Reverse List:::::::::::::::'+reverseList);
lets say List is List<String > TestList = new List<String>{'test1', 'paper'};
for list of reversed strings will be
List<String> newList = new List<String.();
for ( String s : TestList)
{
newList.add(reverse( s));
}
system.debug('======Reversed List======='+newList);
public String reverse( String string ) {
byte[] array = string.getBytes();
byte swap;
for( int i = 0, j = array.length - 1; i < array.length / 2; i++, j-- ) {
swap = array[ j ];
array[ j ] = array[ i ];
array[ i ] = swap;
}
return new String( array );
}
Please mark my answer as solution if it was helpful and give KUDOS.
Hi shasha777,
Please try this one ::
List<String > actualList = new List<String>{'tejpal', 'kumawat'};
List<String> reverseList = new List<String>();
for ( String s : actualList){
reverseList.add(s.reverse());
}
system.debug('Reverse List:::::::::::::::'+reverseList);