answersLogoWhite

0

A class, if designed properly, will provide a grouping of related data and common tasks. Rather than having arrays of primitives all over the place, classes allow us to keep various bits of associated information together.

A common example is a generic Person class...

Trying to keep a list of information about people together without classes will consist of several separate arrays of information:

String[] firstNames;

String[] lastNames;

int[] height;

int[] weight

Obviously, trying to keep these collections of data organized and synchronized will take a great deal of effort.

Compare that to using a Person class:

class Person {

String firstName;

String lastName;

int height;

int weight;

}

Then we only need to keep a single array up to date:

Person[] people;

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Any algo is used for converting class file to java source file?

You need a decompiler to convert class files to java source files. JAD is a Java Decompiler that can do it for you.


Extension file for Java?

Java source files have the .java extension, compiled Java class files have the .class extension.


How do you open a class file?

A (java) class file was not be made to be opened and modified by hand for the users. A class file is the resulting byte code of your java file compilation. This class file can be interpretaded for any jvm. To run your java class you only need to write these instructions in your command line. java [ options ] className [ arguments ... ] java -classpath D:\myprogram MyFileName one two three


The actions in a java class are called?

The actions in a java class are called methods.


Why you start java program by class?

without class non of the folder can run so the java program should start in class we can use the class without object in java


What is classpath and path in java?

if you are using the IDE then there is no need to set class path, ant you are using Command prompt to run the java program then you need to set the class path where the class (which is going to be used in your program) is actually located,use the following command:set calsspath=%classpath%;actual_path_of the class;we cancall more than two class by using this command by using separator (,)


Program in Java to create file and copy content of an existing file to it?

You need to use File class to create file in java and than Reader class implementation such as BufferedReder to read content.


How do you call main class with in main class in java?

We can't call a class. We always call a method in java.


When java uses compiler?

What i know is java we will use compiler when it want to get class file(file with .class extension) from java file(file with .java extension).


What class begins java class hierarchy?

Class


The top most class in java?

All classes in java must inherit from the Object class


What is the way to get rid of Java lang no class deffound error?

To get rid of the Java lang no class deffound error, one must add the class or .jar file which contains this class into the Java classpath. When a Java class is run from the command line, one must add a dot (.)