Java static关键字的几种用法
来源:互联网 发布:软件著作权办理流程 编辑:程序博客网 时间:2024/05/16 14:17
static修饰属性
例如:
public static int sta=0;
static修饰方法
例如:
public static void printfMethod(){}
static代码块
static {}
static导入包
import static java.lang.System.out;
示例代码
import static java.lang.System.out;//静态导包public class HelloStatic { public static int a=10;//静态属性 public static void method(){//静态方法// System.out.println("this is static method");//没有静态导入之前 out.println("this is static method");//静态导入之后 } static {//静态块// System.out.println("this is block of static and static a="+a);//没有静态导入之前 out.println("this is block of static and static a="+a);//静态导入之后 } public static void main(String[] args) {//静态方法 HelloStatic.method(); }}
输出结果
this is block of static and static a=10this is static method
阅读全文
0 0
- Java static关键字的几种用法
- java this关键字的几种用法
- java static关键字用法
- Java关键字static用法
- Java的static关键字的用法
- static的几种用法
- Java关键字final, static的用法总结
- Java关键字final,static的用法总结
- java中static关键字的用法详解
- java中static关键字的用法
- java中关键字static的用法
- java学习笔记-static关键字的用法
- java中static关键字的用法
- java中static关键字的用法总结
- Java学习-static关键字的用法
- static关键字的用法
- static 关键字的用法
- Static关键字的用法
- 将数组元素去重,返回去重后长度
- 欢迎使用CSDN-markdown编辑器
- 2017.10.14 考试
- Codeforces Round #441 (Div. 2, by Moscow Team Olympiad) ABCD题解
- C语言基础练习1
- Java static关键字的几种用法
- Java基础语法试卷5(2017/10/16 第一阶段考试)
- OpenGL学习脚印:缓冲对象相关函数的使用(buffer object function usage)
- java内存空间分析
- 子弹?不存在的
- java实现K叉树及递归和非递归遍历算法
- C++模板类实现Vector
- 1059. C语言竞赛(20)
- Linux gpio 接口