sql 默认值为0_int 默认值为0
生活随笔
收集整理的這篇文章主要介紹了
sql 默认值为0_int 默认值为0
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在java書中:如果沒對int型賦初值,默認是0。
但我們嘗試發現并不能通過:
public static void main(String[] args) { int i; System.out.println(i);}提示:
1 個錯誤
Variable 'i' might not have been initialized
Error:(19, 28) java: 可能尚未初始化變量x
原因:
你定義的i是 臨時變量,這種臨時變量是不會初始化的,只有類的成員變量才會被初始化。比如
然后你創建一個Student對象,new Student(),那么這個對象的屬性i就會被默認初始化為0。
public static void main(String[] args) { Student student = new Student(); //age是student的屬性 System.out.println(student.age);}上面定義了兩個類,在類中new Student,那么Student中的成員變量age就會實例化為0
int
總結
以上是生活随笔為你收集整理的sql 默认值为0_int 默认值为0的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 树莓派python网络通信_Python
- 下一篇: texlive安装需要多久_LaTex编