日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

大数据 java 代码示例_Java变量类型与示例

發布時間:2023/12/1 java 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 大数据 java 代码示例_Java变量类型与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

大數據 java 代碼示例

Java變量 (Java variables)

Variables are the user-defined names of the memory blocks, and their values can be changed at any time during program execution. They play an important role in a class/program as they help in to store, retrieve a data value.

變量是用戶定義的存儲塊名稱,它們的值可以在程序執行期間隨時更改。 它們在類/程序中起著重要的作用,因為它們有助于存儲,檢索數據值。

Java中變量的類型 (Types of the variables in Java)

There are three types of Java variables,

Java變量有三種類型 ,

  • Instance Variables

    實例變量

  • Local Variables

    局部變量

  • Class/Static Variables

    類/靜態變量

  • 1)實例變量 (1) Instance Variables)

    • Instance variables are declared in a class but outside a Method, Block or Constructor.

      實例變量在類中聲明,但在方法,塊或構造函數之外。

    • Instance variables have a default value 0.

      實例變量的默認值為0 。

    • These variables can be created only when the object of a class is created.

      僅當創建類的對象時才能創建這些變量。

    Example:

    例:

    public class Bike {public String color;Bike(String c) {color = c;}public void display() {System.out.println("color of the bike is " + color);}public static void main(String args[]) {Bike obj = new Bike("Red");obj.display();} }

    Output

    輸出量

    Color of the bike is Red

    2)局部變量 (2) Local Variables)

    • Local variables are the variables which are declared in a class method.

      局部變量是在類方法中聲明的變量。

    • We can use these variables within a block only.

      我們只能在一個塊中使用這些變量。

    Example:

    例:

    public class TeacherDetails {public void TeacherAge() {int age = 0;age = age + 10;System.out.println("Teacher age is : " + age);}public static void main(String args[]) {TeacherDetails obj = new TeacherDetails();obj.TeacherAge();} }

    Output

    輸出量

    Teacher age is : 10

    3)類變量/靜態變量 (3) Class Variables/Static Variables)

    • This can be called Both Class and Static Variable.

      這可以稱為類和靜態變量 。

    • These variables have only one copy that is shared by all the different objects in a class.

      這些變量只有一個副本,該副本由類中的所有不同對象共享。

    • It is created during the start of program execution and destroyed when the program ends.

      它在程序執行開始時創建,并在程序結束時銷毀。

    • Its Default value is 0.

      其默認值為0 。

    Example:

    例:

    public class Bike {public static int tyres;public static void main(String args[]) {tyres = 6;System.out.println("Number of tyres are " + tyres);} }

    Output

    輸出量

    Number of tyres are 6

    翻譯自: https://www.includehelp.com/java/variables-types-with-examples.aspx

    大數據 java 代碼示例

    總結

    以上是生活随笔為你收集整理的大数据 java 代码示例_Java变量类型与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。