Shadow Blade
Morrowland Presents Apron Tutorials
game - design - multimedia - web - programming - tutorials - There are currently viewers visiting Apron Tutorials.
   
 
TECHNICAL
GRAPHICAL
SOUND
GAME
WEB
ARTICLE
TOOL
PROJECT
 
 NEWS

  news

  history


 TECHNICAL TUTORIALS

  opengl

  direct3d

  c/c++

  visual basic

  java

  c#


 WEB TUTORIALS

  html

  dhtml

  asp

  php


 IMAGE EDITING

  photoshop

  draw sketch


 3D MODELING

  3d studio


 PROJECTS

  shadow blade

  game environment

  virtual 3d guide

  billy blue flame


 DEMOS

  win32 api


 ARTICLES

  general

  opengl


 COMMUNITY

  about us

  credit

  contact













import java.io.*; // import java.io package

public class Class1
{
	// declare three new integer variables as class members
	public int mySum1;
	public int mySum2;
	public int x;

	// our main function
	public static void main(String[] args) throws IOException
	{
		new Class1(); // call our Class1 constructor
	}

	public Class1() // our class constructor
	{
		// Part I///////////////////////////////
		x = 5;
		myFunc_1();	// call function 1
		System.out.println(mySum1); // display mySum1


		// Part II//////////////////////////////
		// call function 2, pass in the value 5 as an argument.
		myFunc_2(5);
		System.out.println(mySum2); // display mySum2


		// Part III/////////////////////////////
		// display the returned value of function 3
		System.out.println(myFunc_3(5));
	}

	public void myFunc_1() // define function 1
	{
		mySum1 = x + 5;
	}


	public void myFunc_2(int y) // define function 2 with an argument
	{
		mySum2 = y + 3;
	}


	public int myFunc_3(int z) // define function 3 with an integer argument
	{

		return  z + 2;
	}

}

/*
Learn to define different java class member functions.
and see how different functions handles the same type of task,
I have used different numbers so that you easier can tell them appart.



 Let us take a closer look at a function definition:
----------------------------------------------------------------
 public void myFunc_1()
 {
	mySum1 = x + 5;
 }
----------------------------------------------------------------
 public		- mean that this member can be handled by other classes

 void		- means that the function is empty, it returnes no value

 myFunc_1	- the name of the function

 {			- start function definition

 ()			- this means that there are no arguments

 mySum1 = x + 5;	- this is what our function does..

 }			- end function definition
----------------------------------------------------------------
 Decription:
 We must define what our function will do.
 This function takes the number 5,
 and adds it with the value from the argument called x
 and stores the value in the variable mySum.
----------------------------------------------------------------



 Let us take a closer look at a function call:
----------------------------------------------------------------
 myFunc_1();
----------------------------------------------------------------
 myFunc_1	- the name of the function

 ()			- there is no argument passed in

 ;			- end the function call
----------------------------------------------------------------
 Decription:
 You must call your function in order to "put it to work".
----------------------------------------------------------------
*/



Download The Source Code! Download Java Source Code


I hope you found this java tutorial useful!

Don't forget to mention Apron Tutorials in your References!

Best Regards
Ronny André Reierstad

 LINKS

  morrowland home



 GAME DEVELOPEMENT

  nvidia

  gamedev

  polycount


 PROJECTS

  shadow blade

  game environment

  virtual 3d guide

  billy blue flame


 MATH AND PHYSICS

  mathworld

  physicsworld







PLEASE LINK TO


  All rights reserved Morrowland © 2011  
Ronny André Reierstad