Article From:https://www.cnblogs.com/ls-pankong/p/9906735.html

There is always a problem when brushing the questions on each oj. Sometimes the last number does not need to output blanks, but I don’t know what to do. This time I saw a writing method. It feels very good, java’s.

Topic Link: http://acm.hdu.edu.cn/showproblem.php?Pid=2099

package test1;

import java.util.Scanner;
public class Main4 {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      while(sc.hasNext()){
          int n=sc.nextInt();
          int m = sc.nextInt();
          if(n==0&&m==0)break;
        String s="";
         
         for(int i=0;i<100;i++){
             if((n*100+i)%m==0){
                 if(i<10)
                     s=s+0+i+" ";
                 else
                     s=s+i+" ";
             }
             }
         s=s.substring(0,s.length()-1);
     
         System.out.println(s);
      }    
}
    }

The most important thing is this code.

String str = “Hello Java World!”;

The first is: substring(int beginIndex)

      Returns a string from the beginning index to the end of the string

      str.substring(2);

      //return “llo Java World!”;

 

Second species:  substring(int beginIndex, int endIndex)

      Returns a string from the start index to the end index, butInclude no end indexCharacter

      str.substring(2,4);

      //return “ll”;

Link of this Article: Last space problem

Leave a Reply

Your email address will not be published. Required fields are marked *