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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.