Three methods in the range class and simple printing

Source: Internet
Author: User

Package Pkgfirst;

import org.junit.Test;

Public class range{
    
    /**
* Funname:println
* Description: Simple print, instead of 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: Simple print, instead of 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: Simple print, instead of 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: Generates an array from 0 to N, each step 1
* @param: int n
* @return String: Returns an array
* @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: Generates an array from start to End-1, each step 1
* @param: Start, start
* @return String: Returns an array
* @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: Generates an array from start to end, stepping step at a time
* @param: Start, End,step
* @return String: Returns an array
* @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 auto-generated method stub
//simpleprintone sp = new Simpleprintone ();
//sp.println ("Simple println");
//sp.print ("simple print");
//for (int x:range (10,20,12))
//system.out.print (x+ "");

        }
    }


Three methods in the range class and simple printing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.