All the question that scared me now i am trying to scare them .. so that they cant scare others :)
Wednesday, May 2, 2012
Java Fore Cast: why constructor is not define inside Interface?
Java Fore Cast: why constructor is not define inside Interface?: Constructor is used for to intialize the the property or instance variable .but inside the Interface only public, Final and Static variable...
Java Fore Cast: What is Constuctor inside Java?
Java Fore Cast: What is Constuctor inside Java?: 1-constructor is special member of class whose name same as class name . 2 constructor is use to initialize the object state 3 *constru...
Java Fore Cast: Write a java program to reverse a number
Java Fore Cast: Write a java program to reverse a number: Let us suppose that a number is 12345 and we want to reverse this number like 54321 so here is a java program which reverse your any number...
Java Fore Cast: Example of Object class
Java Fore Cast: Example of Object class: We know that Object class is default super class for all the java classes i.e without extending object class we can access the all method...
Java Fore Cast: Example using Garbage Collector
Java Fore Cast: Example using Garbage Collector: Here we explore how JVM call to Garbage collector -gc internally. For this we write two class one is Employee and another is TestGarbageCo...
Java Fore Cast: Example of System class
Java Fore Cast: Example of System class: System class contain three final variables called in, out and err. in: in is a reference variable of type Input Stream and represents alw...
Java Fore Cast: What is Session?
Java Fore Cast: What is Session?: Session is a period of time in which user can send multiple request and get response From client.. In one request user can send mul...
Tuesday, May 1, 2012
How to : Variable Prameters in c# function.
We can use “params” to enable a method to accept variable number of parameters. For using this we can send comma parameter list as somefunction(1,2,3,1,3,4) to the method.
Thursday, April 26, 2012
Java exception : NullPointerException
So suppose you are coding and this "NullPointerException" on the way so what should understand or derive from the exception or moreover how you should proceed for debugging, or getting rid of the exception, to do this lets understand due to what all problems it may cause :
Thrown when an application attempts to use
null in a case where an object is required. These include:- Calling the instance method of a
nullobject. - Accessing or modifying the field of a
nullobject. - Taking the length of
nullas if it were an array. - Accessing or modifying the slots of
nullas if it were an array. - Throwing
nullas if it were aThrowablevalue.
Categories of exceptions in Java
+--------+
| Object |
+--------+
|
|
+-----------+
| Throwable |
+-----------+
/ \
/ \
+-------+ +-----------+
| Error | | Exception |
+-------+ +-----------+
/ | \ / | \
\________/ \______/ \
+------------------+
unchecked checked | RuntimeException |
+------------------+
/ | | \
\_________________/
unchecked
- Checked exceptions: A checked exception is an exception that is typically a user error or a problem that cannot be foreseen by the programmer. For example, if a file is to be opened, but the file cannot be found, an exception occurs. These exceptions cannot simply be ignored at the time of compilation.
- Errors: These are not exceptions at all, but problems that arise beyond the control of the user or the programmer. Errors are typically ignored in your code because you can rarely do anything about an error. For example, if a stack overflow occurs, an error will arise. They are also ignored at the time of compilation.
- Runtime exceptions: A runtime exception is an exception that occurs that probably could have been avoided by the programmer. As opposed to checked exceptions, runtime exceptions are ignored at the time of compliation.
trimToSize or trimTolength
This method is sometime very useful for memory management suppose you know value you have assigned to an array list will be final means no more element addition to the array list you can use this to make the memory smaller for that array list
Trims the capacity of this ArrayList instance to be the list's current size. An application can use this operation to minimize the storage of an ArrayList instance.
An application can use this operation to minimize the storage of an ArrayList instance.
Example:
Trims the capacity of this ArrayList instance to be the list's current size. An application can use this operation to minimize the storage of an ArrayList instance.
An application can use this operation to minimize the storage of an ArrayList instance.
Example:
ArrayList myAL = new ArrayList();
myAL.Add( "Shashwat" );
myAL.Add( "Shriparv" );
So now you know that no more element will be added to myAl, so you can apply:
myAl.trimToSize() to make memory alocation smaller and efficient.
Subscribe to:
Posts (Atom)
Featured Posts
How to Enable and Configure Remote Desktop (RDP) on Ubuntu 24.04.4 LTS
Remote Desktop Protocol (RDP) support in Ubuntu has become considerably easier with the GNOME Remote Desktop stack included in modern Ubuntu...
-
public struct CoOrds { public int x, y; public CoOrds( int p1, int p2) { x = p1; y = p2; } }
-
LM Studio Overview LM Studio is a desktop application designed for developing and experimenting with large language models (LLMs)...