标签:
package pkgFirst;
import org.junit.Test;
public class Range{
/**
* FunName: println
* Description : 简版打印,代替System.out.println(object)
* @param: object being print
* @return String: none
* @Author: Bingoreo
* @Create Date: 2015-07-15
**/
public static void println(Object obj){
System.out.println(obj);
}
/**
* FunName: println
* Description : 简版打印,代替System.out.print(object)
* @param: object
* @return String: none
* @Author: Bingoreo
* @Create Date: 2015-07-15
**/
public static void print(Object obj){
System.out.print(obj);
}
/**
* FunName: println
* Description : 简版打印,代替System.out.println()
* @param: none
* @return String: none
* @Author: Bingoreo
* @Create Date: 2015-07-15
**/
public static void println(){
System.out.println();
}
@Test
/**
* FunName: range
* Description : 生成从0到n的数组,每次步进1
* @param: int n
* @return String: 返回数组
* @Author: Bingoreo
* @Create Date: 2015-07-15
**/
public static int[] range(int n){
if (n <=0)
return null;
else {
int[] inCount = new int[n];
for(int i =0; i<n ; i++){
inCount[i] = i;
}
return inCount;
}
}
@Test
/**
* FunName: range
* Description : 生成从start到end-1的数组,每次步进1
* @param: start, start
* @return String: 返回数组
* @Author: Bingoreo
* @Create Date: 2015-07-15
**/
public static int[] range(int start, int end){
if (start >= end)
return null;
else{
int[] inCount = new int[end - start];
for(int i =0; i<end-start ; i++){
inCount[i] = end - start + i;
}
return inCount;
}
}
/**
* FunName: range
* Description : 生成从start到end的数组,每次步进step
* @param: start, end,step
* @return String: 返回数组
* @Author: Bingoreo
* @Create Date: 2015-07-15
**/
public static int[] range(int start, int end, int step){
if (start >= end)
return null;
else{
int n = (end - start)/step + 1;
int[] inCount = new int[n];
for(int i =0; i<n ; i++){
inCount[i] = (end - start) + step*i;
}
return inCount;
}
}
public static void main(String[] args) {
// TODO 自动生成的方法存根
//SimplePrintOne sp = new SimplePrintOne();
//sp.println("simple printLn");
//sp.print("simple print");
//for(int x :range(10,20,12))
//System.out.print(x+" ");
}
}
标签:
原文地址:http://www.cnblogs.com/tuanfuyao/p/4648112.html