Data Types – 2 types
- Variables must always declared with a name and a type.
- Class - First letter CAPS for each new word ex : SavingGoal
- Function(method) - First Letter SMALL ex : updateSavings()
- Variable - First Letter SMALL ex : Dog tommyHigh
- Packages - all SMALL letters ex :
- Constructors - First letter CAPS for each new word (like class) ex : SavingGoal
Ex : int x = 8 ;
Type Bit-Depth Value-Range Default value
boolean JVM specific true,false false
char 16 bits 0 to 65535
byte 8 bits -128 to 127
short 16 bits -32768 to 32767
int 32bits -2147483648 to 2147483647
long 64 bits -huge to huge
float 32 bits varies
double 64 bits varies
Ex : Dog myDog = new Dog();
The value of the variable is bits representing a way to get to a specific object
(.) Dot operatore is used to refer the value in reference variable.
It's default value is null when not referening any object.
Arrays - it is always an object.
ex: nums = new int;
Once you declared an array, you can't put anything in it except things that are of the declared array type.
However you can put a byte into an int array. it is implicit widening.
- Class - is a blueprint for an object.
- Description for JVM to make object is nothing but a class.
- Class consists instances (instance variables) and methods.
- Mark instance variables private
- Mark getters and setters public(get and set methods)
- Instance variables always gets default value.
- Local variables(variables in methods) do NOT get a default value.Compiler reports error for this.
- Use == to compare two primitives or two references ex : int a = 4; int b = 4; if (a == b) print x;
- USe the equals() method to see if two different objects are equal(such as two different String objects).
- Java uses pass by value - " pass by value is passing by copy".
1 comments to "Java lessons learned - Naming Convention, Variables,Data Types, Arrays"
Powered by WidgetsForFree
- ► 2013 (19)
- ► 2011 (18)
- ► 2010 (35)
- ► 2009 (73)
- Deepavali Vs Goddess of sleep
- Dream home designer software - Google SketchUp
- Old is Bold - New is Italic
- Solaris Commands - Tips - Installtion - All about ...
- Microsoft PowerToys for Windows XP
- Handy tools for Browser Testing (IE6, IE7, FF)
- BSNL Dial up Connectiion
- IE7 - runonce.msn.com/runonce3.aspx
- JRE - Browsers ( IE, Firefox)
- Trip to Kolar, Kotilingeshwara, Bangaru Tirupati, ...
- Java lessons learned - Naming Convention, Variable...
- Andhra to America
- Is your blog listed under unauthorized Web pages w...
- Number of files in a directory
- Online Payment methods for different credit cards
- ▼ October (16)
My Blog List
- Airtel and vodafone GPRS settings for pocket PC phones
- Andhra 2 America
- Ayyappa Deeksha required things
- Blogs I watch !
- Captions for your bike
- DB2 FAQs
- Deepavali Vs The Goddes of sleep
- ETV - Dhee D2 D3
- Evolution of smoking in India Women
- How to make credit card payments?
- Java-J2EE interview preparation
- My SQL FAQs
- My Travelogues
- Old is blod - New is italic
- Online pay methids for credit cards
- Oracle FAQs
- Smoking in Indian Women
- Technology Vs Humans
- Twitter feeds for all Telugu stars on single page.
- Unix FAQs
- Unix best practices
- init 0, init 1, init 2 ..
- mCheck Application jar or jad download