![]() These two lines will crash the program because no value is specified for x and we are trying to use x's value to specify y. For example variables of type Object are references.Ĭonsider the following code where you declare a variable of primitive type int and don't initialize it: int x By convention reference types are usually denoted with a type that starts in uppercase. to access a method or field, or using [ to index an array. If you want to manipulate the Object that a reference variable refers to you must dereference it. References: variables that contain the memory address of an Object i.e. For example variables of type int or char are primitives. ![]() By convention primitive types start with a lowercase letter. If you want to manipulate the data in a primitive variable you can manipulate that variable directly. There are two overarching types of variables in Java:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |