0% found this document useful (0 votes)
13 views3 pages

Java Variables and Parsing Methods Guide

The document discusses Java programming concepts, focusing on the use of classes, variables, and methods. It outlines the differences between local, instance, and class variables, including their scope, lifetime, memory location, default values, and access modifiers. Additionally, it covers parsing methods for converting strings to primitive types using wrapper classes in Java.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Java Variables and Parsing Methods Guide

The document discusses Java programming concepts, focusing on the use of classes, variables, and methods. It outlines the differences between local, instance, and class variables, including their scope, lifetime, memory location, default values, and access modifiers. Additionally, it covers parsing methods for converting strings to primitive types using wrapper classes in Java.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

To packets are essentials

[Link]
[Link]

Here we use extends keyword to create a Child class from a parent class.

W02_9 inside class


Feature Local Variable Instance Variable Class Variable (static)
Declared Method, constructor, or Inside class, but outside Inside class with static
inside block any method keyword
Available to all
Available only within that Available to all objects
Scope methods/constructors of
method/block of the class
object
Created when method starts, Exists as long as object Exists as long as class is
Lifetime
destroyed when ends exists loaded in memory
Memory Heap (each object has its Method area / Class
Stack
location own copy) area (single shared copy)
❌ Must be initialized ✅ Default values assigned ✅ Default values assigned
Default value
before use automatically automatically
Through object reference Through class name
Access Only inside the method
([Link]) ([Link]) or object
Modifier Can use access modifiers Must use
Cannot use static
allowed (public, private) static

Println- after printing goes to next line


Print- after printing curser not goes to next line
Print(“/n”)—used to start newline

We can use printf command also, when we use Printf the formatting print will go on, so we
need to follow the rules as in C/C++
V= [Link](arg[])

Converts string input (args[]) into Int format, Integer is a class in [Link], parseInt is a
method.

[Link](args[])

[Link](args[])

[Link](args[])
etc

Wrapper Class Primitive Type Parsing Method Example


Integer int int x = [Link]("123");
Double double double d = [Link]("12.34");
Float float float f = [Link]("3.14");
Long long long l = [Link]("12345");
Short short short s = [Link]("10");
Byte byte byte b = [Link]("5");
Boolean boolean boolean flag = [Link]("true");
[Link].

You might also like