Java-arrays class-fill () method detailed

Source: Internet
Author: User

Fill () Method use reference

Examples of declarations:

 Public Static void Fill (intint

Parameters:

a--Array

form--Replace start position (included)

to--Replace end position (not included)

var--the value to replace

Use a reference instance:

 Public classTest { Public Static voidMain (string[] args) {int[] A =New int[]{1,2,3,4,5,6};  System.out.println (Arrays.tostring (a)); //{1,2,3,4,5,6}Arrays.fill (A,0);  System.out.println (Arrays.tostring (a)); //{0,0,0,0,0,0}                int[] B =New int[]{1,2,3,4,5,6}; Arrays.fill (b,2, 4, 0);  System.out.println (arrays.tostring (b)); //{1,2,0,0,5,6}boolean[] C= {true,false};  System.out.println (Arrays.tostring (c)); //{True,false}Arrays.fill (c,false);  System.out.println (Arrays.tostring (c)); //{False,false}Arrays.fill (c, 0, 1,true);  System.out.println (Arrays.tostring (c)); //{True,false}string[] D= {"A", "B", "C", "D", "E", "F"};  System.out.println (arrays.tostring (d)); //{a,b,c,d,e,f}Arrays.fill (d, 1, 2, "HelloWorld"));  System.out.println (arrays.tostring (d)); //{a,helloworld,c,d,e,f}            }}

Java-arrays class-fill () method detailed

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.