IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesJava  Print This     

Custom Routines (Java and Delphi Cross Reference Guide)

By Mike Prestwood

Java versus Delphi: A side by side comparison between Java and Delphi.

 
Language Details
 

Language Details is kind of a catch all for stuff that didn't make it into language basics nor any other category.

Custom Routines

[Other Languages] 

Languages Focus

For non-OOP languages, a custom routine is a function, procedure, or subroutine and for pure OOP languages, a custom routine is a class method. Hybrid languages (both non-OOP and OOP) combine both.

Java: 

Because java is an OOP language, all custom routines belong to a specific class and are therefore referred to as methods.

All methods in Java must return something so even with procedures, you return a "void".

Syntax Example:
public void sayHello(String pName) {
  System.out.println("Hello" + pName);
}
 

public int add(int p1, int p2) {
  return p1 + p2;
}
Delphi:   procedure, function

Delphi is a hybrid language so you can create either class methods (functions and procedures) or you can create global functions and procedures. When a function or procedure is part of a class, it is a class method.

[function/procedure] RoutineName : ReturnType;

As with C++, your custom routine must come before it's first usage or you have to prototype it in the Interface section.

Note: Contrast Delphi with Delphi Prism which is an OOP language (everything is within a class). Both Delphi and Delphi Prism are based on Object Pascal but implement OOP features differently and have some syntax differences too.

Syntax Example:
procedure SayHello(pName: String);
begin
  ShowMessage('Hello ' + pName);
end;
 
function Add(p1, p2 : Double): Double;
begin
  Result := p1 + p2;
end;












Sales Website: www.prestwood.com Or visit our legacy sales site: 
legacy.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]