zoukankan      html  css  js  c++  java
  • 什么是对象:EVERYTHING IS OBJECT(万物皆对象)

    面向对象主要针对面向过程。

    面向过程的基本单元是函数。

     

    什么是对象:EVERYTHING IS OBJECT(万物皆对象)

     

    所有的事物都有两个方面:

    有什么(属性):用来描述对象。

    能够做什么(方法):告诉外界对象有那些功能。

    后者以前者为基础。

    大的对象的属性也可以是一个对象。

     1 package TomText;
     2 
     3 public class TomText_01 {
     4      public static void main(String[] args){
     5           
     6           method(99); //求n之前的奇数的和的方法
     7          }
     8          
     9          public static void method(int n){
    10           
    11           int j = 0;   //奇数
    12           int sum = 0; //n之前的奇数的和
    13           int m = (n+1)/2; //n之前的奇数的个数
    14           
    15           for(int i=0;i<m;i++){
    16            
    17            j = 2*i+1;  //第i+1个奇数的值,i初始为0
    18            sum += j;   //计算n之前的奇数的和
    19           }
    20           
    21           System.out.println(sum);//打印结果
    22          }
    23 }
  • 相关阅读:
    jq---方法总结
    Coderfroces 862 B . Mahmoud and Ehab and the bipartiteness
    Coin
    joisino's travel
    日天的终生大事(dp)
    Codefroces 852 G. Bathroom terminal
    Codefroces432 div2 A,B,C
    Atcoder ABC 069 C
    Codefroces 849 A,B
    HDU 6186 CS Course
  • 原文地址:https://www.cnblogs.com/borter/p/9418477.html
Copyright © 2011-2022 走看看