Implementing object-Oriented Programming with Java (11)

Source: Internet
Author: User

Joseph Ring Question:

Package com.zb.test;

public class Yuesefu

{
public static void Main (string[] args)

{
500 people Group
Boolean[] B = new boolean[500];
for (int i = 0;i < b.length;i++)

{
B[i] = true;//means that everyone is alive.
}
int sum = b.length;//Total is 500
int index = subscript for number of 0;//
int count = 0;//a variable
while (Sum > 1)//When the number of surviving >1 people

{
if (B[index])//If this person is alive at the moment

{
count++;//to the number of reports
if (count = = 3)//If report 3 is shot

{
Total sum--;//-1
B[index] = false;//This person is now dead.
Count = 0;//Restart off
}
}
index++;//subscript move to next person
if (index = = 500)//if subscript to 500 means 1 laps have ended re-counting

{
index = 0;
}
}
for (int i = 0;i < b.length;i++)

{
if (B[i])

{
System.out.println ("The Living position is:" + (i+1));
}
}
}
}

Method

GetMethod: Gets the public-decorated method of a class if there is a method that inherits the parent class that exists in the subclass

Getdeclaremethod: Gets the method declared in the class even if it is decorated with private

Implementing object-Oriented Programming with Java (11)

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.