Home > Back-end >  Help: Java programming: using the recursive function call, will enter the ten characters, printed in
Help: Java programming: using the recursive function call, will enter the ten characters, printed in

Time:09-21

As title, thanks for your bosses ~ ~
I haven't learn recursion is what,,, ah it,,,,

CodePudding user response:

Recursion is call themselves, in the method with judgment decision is to continue to call themselves, or the end of the call,

CodePudding user response:

reference 1st floor aw277866304 response:
is recursive call themselves, in the way with judgment decision is to continue to call themselves, or the end of the call,

Ah yes, I go to Chou Chou

CodePudding user response:

A
 static Scanner input=new Scanner (System. In); 
Public static void test1 () {
System. The out. Println (" please enter the characters no end ");
Xx=input String. The next ();
If (" no ". The equals (xx))
return ;
test1();
System. The out. Print (xx + "\ t");
Second}
 public static void test2 (String [] arr, int index) {
If (arr. Length==index) return;
Test2 (arr, index + 1);
[index] System. Out. Println (arr);
}

CodePudding user response:

 package test. Gt80; 

Public class Test98 {

Public static void main (String [] args) throws the Exception {
String STR="12345";
Test (STR, STR. Length ());
}

Public static void test (String STR, int length) {
If (length==0)
return;
System. The out. Print (STR. CharAt (length - 1));
The test (STR, length - 1);
}
}

CodePudding user response:

 public class Test2 {

Public static void main (String [] args) {

String param="people is my country in the";

System. The out. Println (doEvert (param));

}

Public static String doEvert (String param) {
If (StringUtils. IsEmpty (param. The trim ())) {
Return param.
}
If (param length ()==1) {
Return param.
}
Return param. Substring (param length () - 1) + doEvert (param. Substring (0, param. Length () - 1));
}
}
  • Related