Constructors that Allocate Memory Dynamically

Constructors that Allocate Memory Dynamically

Constructors can be used to initialize member objects as well as allocate memory. This can allow an object to use only that amount of memory that is required immediately. This memory allocation at run-time is also known as dynamic memory allocation. The new operator is used for this purpose. Sample Program The program below shows the use of new in constructors of a simple String class.   /* * Program to illustrate use of dynamic memory allocation * in constructors * http://w

[ Read Constructors that Allocate Memory Dynamically ]

Kruskal’s Algorithm

Kruskal’s Algorithm

An algorithm which is used to create a minimum spanning tree is attributed to Kruskal's algorithm. The nodes of the graph are initially considered as n distinct partial trees with one node each. At each step of the algorithm, two distinct partial trees are connected into a single partial tree by an edge of the graph. When only one partial tree exists (after n-1 such steps), it is a minimum spanning tree. The concern is what connecting arc to use at each step. The answer is to use the arc of min

[ Read Kruskal’s Algorithm ]

Deleting an Element from a Doubly Linked List

Deleting an Element from a Doubly Linked List

To delete an element from the list, first the pointers are set properly and then the memory occupied by the node to be deleted is deallocated (freed). Deletion in the list can take place at the following positions. At the beginning of the list At the end of the list After a given element Before a given element Deleting from the Beginning of the List An element from the beginning of the list can be deleted by performing the following steps: Assign the value of head (address o

[ Read Deleting an Element from a Doubly Linked List ]

NoClassDefFound

NoClassDefFound

NoClassDefFound means "No Class Definition Found". NoClassDefFound is an error from the JVM when it cannot find a class required to run a Java program. This error could be caused by an actual missing class, but it is usually caused by a faulty CLASSPATH. This error also sometimes occurs when Java users add the unnecessary .class extension to the end of their command lines: C:>java HelloWorld.class Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld/class C:

[ Read NoClassDefFound ]

Static Class Members

Static Class Members

The members (data members and member functions) of a class may be qualified as static by preceding member declaration with the keyword static. There may be static data members and static member functions in a class. Static Data Member A static data member of a class is just like a global variable for its class. That is, this data member is globally available for all the objects of that class type. The static data members are usually maintained to store values common to the entire class. For in

[ Read Static Class Members ]

Java Operators

Java Operators

Java Operator Operator Description [ ] Array index () Method call . Member access ++ Prefix or postfix increment -- Prefix or postfix decrement + - Unary plus, minus ~ Bitwise NOT ! Boolean (logical) NOT (type) Type cast new Object creation * / % Multiplication, division, remainder + - Addition, subtraction + String concatenation << Signed bit shift left to right >> Signed bit shift rig

[ Read Java Operators ]

Hex Editor

Hex Editor

A hex editor is a program edits compiled programs and binary data files. These editors are called hex editors because they most often present data in hexadecimal format. Hexadecimal is used because it is easier for most humans than working in binary. In addition, hexadecimal is frequently useful because computers tend to work with 8-bit bytes of information and because ASCII is an 8-bit code. Some hex editors are also able to edit raw disk partitions and other file system structures. He

[ Read Hex Editor ]

JDK (Java Development Kit)

JDK (Java Development Kit)

JDK is an abbreviation for Java Development Kit. The JDK product, formerly owned by Sun Microsystems, is now owned and maintained by the  Oracle Corporation. JDK is licensed under the GNU General Public License (GPL). That is, JDK is a free to use software package. It is a comprehensive development environment primarily aimed for Java developers. It basically envelops a run-time environment that is stacked on top of a operating system. Other tools needed by a Java progammer to code, compile

[ Read JDK (Java Development Kit) ]

Constructor

Constructor

A constructor is a special dedicated method to initialize a new instance of a class. The constructor method for a class will have the same name as the class. A class can contain more than one constructor method, but each having a different set of parameters. They are called overloaded constructor methods. A constructor method is the first method that's called and executed when a new object is instantiated. It's primary usage is to assign default values to variables, do basic cleanup or calcul

[ Read Constructor ]

Override

Override

Sometimes a subclass inherits a method from a superclass that doesn't quite fit its needs. Perhaps the subclass inherited twenty methods and just one of them wasn't quite right. In that case, the subclass would override that method by redefining that method itself. This override does not affect the method as defined in the superclass.

[ Read Override ]

Page 1 of 161234Last »