Posts

Arrays In Java

Arrays In Java Arrays: It can be defined as the collection of similar elements together . Array Size Starts from "0" and ends at "n-1" Example:  Collection of student roll numbers comes under one single integer array. Collection of student names comes under one single String array. Collection of Faculty salarys comes under one single Float array. Types Of Arrays: There are three types of arrays they are : One/Single dimensional array Two Dimensional array Multi Dimensional array 1.One/Single Dimensional Array: One Dimensional array is used to collect the set of elements together . The Size of the array can be defined as "Product of number of bytes of datatype and size of the array."  Size of an array= number of bytes used by datatype * size of the array. Syntax: Initializing an array: <datatype>[] variable={values}; Example for initializing : int[] a={10,20,30,40}; Declaring an array: ...

Java Blocks

Blocks in java Block: A set of statements together is called as block. The set of statements are written inside the flower braces {}. In java there are two types of Blocks they are : Instance Block. Static block. Instance Block: Instance block is a set of statements written within the flower braces and will execute when an object is created . Instance blocks will not have any name. Instance blocks will completely depends on the object of a class created . Syntax: {     set of statements; } Program Using Instance Block class InstanceBlock { InstanceBlock() { System.out.println("Location Of Institute : Dilsuknagar"); } //Instance Block { System.out.println("Name Of Institute : Void Main Technologies"); } } class InstanceBlockTest { public static void main(String[] args)  { InstanceBlock ib=new InstanceBlock(); } } Save as: InstanceBlockTest.java Compile: javac In...