🔒 Closed Baka may maka help about swapping numbers

Status
Not open for further replies.

Nieru

Forum Veteran
1671070550356.png
hindi ko makuha mga paps, nauubusan ako ng idea e. pahelp naman mga paps

Calling po sa mga expert dyan
 
If no rule sa pagcode you can use this String method:

Java:
public class Main {
  public static void main(String[] args) {
String out = swap("123456");
     System.out.print("Out: " + out);
    }
    
    public static String swap(String str){
     return str.charAt(str.length()-1) +
     str.substring(1, str.length() - 1) +
     str.charAt(0);
  }
}
 
If no rule sa pagcode you can use this String method:

Java:
public class Main {
  public static void main(String[] args) {
String out = swap("123456");
     System.out.print("Out: " + out);
    }
   
    public static String swap(String str){
     return str.charAt(str.length()-1) +
     str.substring(1, str.length() - 1) +
     str.charAt(0);
  }
}
awts medyo advance na ata yan paps, pero salamat parin
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 2
    Replies
  • 529
    Views
  • 2
    Participants
Last reply from:
Nieru

Trending Topics

Online now

Members online
1,105
Guests online
3,397
Total visitors
4,502

Forum statistics

Threads
2,307,181
Posts
29,177,174
Members
1,193,287
Latest member
bahogbilatte
Back
Top