English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Pascal, C and Ada programers have records and structures, what do Java programmers use instead. Also, do you have to put a class into a package in order to use it or import it into another file/program/application? Examples? I am attempting to learn Java on my own until I get a class this summer. Thanks in advance. FWIW if you answer my questions, you will be the first to do so, that includes www.sun.com and the java website too.

2007-03-19 09:32:24 · 4 answers · asked by rhohltjr 1 in Computers & Internet Programming & Design

4 answers

The answer to your first question is that the concept of a structure as in Pascal, C and Ada and other structured programming languages does not actually exist in Java.
It is just a series of variables updated in a class or method that generates an output record.
Try to think of it as more of a black box. The black box will either have variables to be set of setter methods to set the values of the variables.
Once set there will be a write or a pass data-to method that will do the next step. You don't need to know what it does or how it does what it does.
OK so you are writing the code but try and design the class structure with this in mind.
This way the write method could actually write the data to a file or to a database. The program does not need to know what it does. This means that if the output method changes then the program will not be affected.
A package is just a way of seperating out parts of a java program. Look at java classes that are available. these are already in packages that define the type of useage that the classes have ie. java.lang.*
You do not have to put your classes into a package.

2007-03-19 10:02:41 · answer #1 · answered by AnalProgrammer 7 · 0 0

Hi, just a note for you. Berkeley has free videos on java programming. Use "CS 61B Data Structures" in the below link. Awesome, is all I can say. Nice way too learn on your own. Navigate with the drop down list box, once there, to find other semesters. Other courses cover perl, c, and others.

2007-03-19 10:11:18 · answer #2 · answered by ResourceGuy 4 · 0 0

Classes. When you program in Java you need to declare a class

public class Test{

public static void main( string Args[] )
{
System.out.println("Hello World");
}
}
Then you should save this file with the name Test.java

to declare a package you need to use the name package plus the name of the package

package myPackageTest;

2007-03-19 09:41:30 · answer #3 · answered by Anonymous · 0 0

I understand what you mean. I'm a C# programmer. Anyway, I hope this link helps you out.

http://java.sun.com/docs/books/tutorial/java/package/packages.html

2007-03-19 09:40:41 · answer #4 · answered by Raise The Bahr 2 · 0 0

fedest.com, questions and answers