hello every one, how are you?!

I come back after long absent ,, and I want help from you,,

just small question :D

Suppose you wish to write a method that prints a heading on a new output page, along with a page number that is 1 in the first activation and that increase by 1 with each subsequent activation.
Can this be done without parameters and without reference to nonlocal variables in java ?
Also, can it be done in C#?


I need answer in short time.. please help me :)

Something like this?

int pageNumer = 0;   //instance variable for main class
 
public void newPage(String heading)
{
	pageNumber++;
	if (heading == null)
		 heading = "New Page: "+pageNumber
	else
		 heading.concat(pageNumber);
	
	System.out.println(heading);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.