Why processing an unknown number of parameters, JAVA Programming

Assignment Help:

Why Processing An Unknown Number Of Parameters ?

Most of the time you have a fairly high-quality idea of what parameters will and won't be passed to your applet. Therefore some of the time there will be an undetermined number of parameters. For example Sun's imagemap applet passes each "hot button" as a parameter. Different imagemaps have different numbers of hot buttons. Another applet might need to pass a series of URLs to different sounds to be played in order. Each URL could be passed as a separate parameter.

Or perhaps you need to write an applet in which displays various lines of text. Although it would be possible to cram all this information within one long string, that's not too friendly to authors who need to use your applet on their pages. It's much more sensible to give each line its own PARAM element. If this is the case, you should name the tags thorugh some predictable and numeric scheme. For instance in the text example the by set of PARAM elements would be sensible:

< PARAM name="Line1" value="There once was a man from Japan">
< PARAM name="Line2" value="Whose poetry never would scan">
< PARAM name="Line3" value="When asked reasons why,">
< PARAM name="Line4" value="He replied, with a sigh:">
< PARAM name="Line5" value="I always try to get as many
syllables into the last line as I can.">

The program below displays this limerick. Lines are accumulated within an array of strings called poem. A for loop fills the array along with the various lines of poetry. There are 101 spaces in the array, but since you won't normally required that several, an if clause tests to see whether the attempt to get a parameter was successful through checking to see if the line is null. As soon as one fails, the loop is broken. Once the loop is finished numLines is decremented through one because the last line the loop tried to read was not there.

The paint() method loops through the poem array and prints each String on the screen, incrementing the y position through fifteen pixels each step so you don't draw one line on top of the other.


Related Discussions:- Why processing an unknown number of parameters

What is application context, A bean factory is fine to easy applications, b...

A bean factory is fine to easy applications, but to take benefit of the full power of the Spring framework, you may require to move up to Springs more advanced container, the appli

Explain about the performance aspects of core java, Performance of interpre...

Performance of interpreted byte codes is sufficient but it can be improved much more than that. Byte codes are changed into machine language within no time, this speed of implement

Excel file to responsive css/html page, Excel File to Responsive CSS/HTML p...

Excel File to Responsive CSS/HTML page Project Description: Excel file to be converted into a responsive form for a site. In the excel file you will see where the input field

What is role of action class, An Action Class performs a role of an adapter...

An Action Class performs a role of an adapter among the contents of an incoming HTTP request and the corresponding business logic that should be implemented to process this request

What is asynchronous messaging, What is asynchronous messaging? Queue An...

What is asynchronous messaging? Queue Ans) Asynchronous messaging includes a client that does not wait for a message from the server. An event is used to trigger a message from

What is a packet in the network environment, What is a packet within the ne...

What is a packet within the network environment? What kind of information does it contain? A packet is the shortest unit of data transmitted over a computer network. It's a mes

Generating Dynamic form, I am having an combox box and values are retrieved...

I am having an combox box and values are retrieved from the database having inputs and labels i want to created the dynamic form accroding to user input on combox box values

What is invoking static methods, What is Invoking static methods If a m...

What is Invoking static methods If a method or field is declared static, you access it through using the class name rather than a reference to a particular example of the class

Explain arithmetic promotion and binary operations, Explain Arithmetic Prom...

Explain Arithmetic Promotion and Binary Operations? An int divided through an int is an int, and a double divided by a double is a double, but what about an int divided by a do

What is an aspect, An aspect is the cross-cutting functionality that you ar...

An aspect is the cross-cutting functionality that you are executing. It is the aspect of your application you are modularizing. An example of an aspect is logging. Logging is somet

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd