Java articles

Share
|
Homepage | Submit your article | Contact | TOS
More articles on java  

Navigation: Categories » Computers and technology » java

Go to Page# 1 2

Advantages of exceptions in Java programming language (04/30/2012)
... Advantage 2: Propagating Errors Up the Call Stack A second advantage of exceptions is the ability to propagate error reporting up the call stack of methods. Suppose that the readFile method is the fourth method in a series of nested method calls made by the main program: method1 calls method2, which calls method3, which finally calls readFile: method1 { call method2; } method2 { call method3; } method3 { call readFile; } Suppose also that method1 is the only method interested in the errors that might occur within readFile. traditional error-notification techniques force method2 and method3 to propagate the error codes returned by readFile up the call stack until the error codes finally reach method1the only method that is interested in them: method1 { errorCodeType error; error = call method2; if (error) doErrorProcessing; else proceed; } errorCodeType method2 { errorCodeType error; error = call method3; if (error) return error; else proceed; } errorCodeType method3 { errorCodeType error; error = call readFile; if (error) return error; else proceed; } Recall that the Java runtime environment searches backward through the call stack to find any methods that are interested in handling a particular exception. A method can duck any exceptions thrown within it, thereby allowing a method farther up the call stack to catch it. Hence, only the methods that care about errors have to worry about detecting errors: method1 { try { call method2; } catch (exception e) { doErrorProcessing; } } method2 throws exception { call method3; } method3 throws exception { call readFile; } However, as the pseudocode shows, ducking an exception requires some effort on the part of the middleman methods....
What should you know before you ship your Java applet ~ The perfectly finished applet (08/18/2010)
... 3. If the applet does something that might get annoyingplay sounds or animation, for exampledoes it give the user a way of stopping the annoying behavior? Be kind to your users. Give them a way to stop the applet in its tracks, without leaving the page. In an applet that otherwise doesn't respond to mouse clicks, you can do this by implementing the mouseDown method so that a mouse click suspends or resumes the annoying thread. For example: boolean frozen = false; // an instance variable public boolean mouseDown(Event e, int x, int y) { if (frozen) { frozen = false; start(); } else { frozen = true; stop(); } return true; } The Perfectly Finished Applet The previous section lists some of the ways you can avoid making your applet's users want to throttle you....
Deploying Java Applets in a Mixed Browser Environment (08/09/2010)
... 2. Use the document.write() method to write a tag based on the value of the appName variable: If the browser name equals "Netscape", write the embed tag. If the browser name equals "Microsoft Internet Explorer", write the object tag. In the following example, the document....
Why Java programmers are taking one step ahead in software development industry (07/21/2009)
... Benefits of Java 1. Complex dynamic web applications are possible in Java programming. 2. Java is multi threaded programming language so is used in high performance applications. 3....
SELECTION STATEMENTS IN JAVA (03/04/2009)
... So we study both of them in detail. 1. IF STATEMENT: The simple if statement is very simple to understand. It checks out a condition, and if finds it true, it executes the if block statements, otherwise not. The if statements are executed if and only if the condition is true....
JAVA and its Advantages (02/05/2009)
... Many companies in India have well-qualified software engineers having expertise in Java, Java Script, J2SE, JSP, and J2ME, JAVA Programming Services help your businesses to do better. They provide variety of Java development services including project solutions. Author Bio: Outsourcing programming services is a leading outsourcing programming services Provider Company. For more info please visit at: http://www.outsourcingprogrammingservices....
Java Tactics: Earn A Fortune With Java (07/09/2008)
... I for one believe that the code we developers write, is a work of art, and we deserve a fancy lifestyle for that, after implementing these tactics, you'll get the cash rewards you deserve as a Java programmer. The following 6 tactics will guarantee you a balance of Measurement and Leverage, so the financial rewards will be great: Tactic 1: The First Timer Well you've probably heard the story that in order to make it in programming, you need a Computer Science degree, well I'm here to tell you that you don't, yes it does have its advantages but it's not the only way to enter the programming field, a good diploma can be just as good as a CS degree. Ok, well now that you've got the qualification, what's next? Tactic 2: Strategic Java Moves Well as for this section, a lot of companies wouldn't want their employees getting hold of this information because honestly, this is no new strategy, it already exists except that only a few people know about it, once you find out what it is, you'll bang your head against the wall for not thinking about it in the first place, this section also requires good negotiation skills so I’ll touch on the important tips a little bit. This is one of my favorite tactics because you can keep doing it over and over again until you think you’ve got enough cash in your pocket, but I advice people to be very careful when using this strategy because if used wrongly, it might affect your name and career badly. Large Corporations exploit their developers badly, but I've found a way around it, and it's completely foolproof....
Introduction to Object Oriented Programming (OOP) (01/03/2008)
... Methods provide the functionality of the object and can be used to interact with the attributes. Methods are also known as functions or procedures in various other programming languages. Object-Oriented Programming in Java The Java language is completely object oriented. This means that there are no global statements whatsoever (although static members can be conceived as being somewhat global—we will discuss static members later). Any attributes or methods must be defined as part of a class or interface....
Operator Precedence in programming languages (01/03/2008)
... When in doubt, it is recommended that you use parentheses to specify the order of operations. It is often best to use parentheses anyway to make your code more understandable. The following table shows an operator list containing operators with a higher precedence at the top and thoses with a lower precedence at the bottom. The table also shows the associativity of grouped operators that are of equal precedence. The associativity deciphers the order of operators of equal precedence....
Arithmetic Assignment Operators (01/03/2008)
...........
Bitwise Operators (01/03/2008)
... Byte Bits A 0 1 1 0 1 0 1 0 B 1 1 1 1 0 0 0 0 A AND B 1 0 0 1 1 0 1 0 The NOT (~) operator will invert all of the bits, where ones becomes zeros and zeros become ones, and is therefore a unary operator used with only one operand, whereas the other bitwise operators we have just seen were tested against two operands (binary operators), A and B. The following table shows the result of a NOT operation on byte A. Byte Bits A 0 1 1 0 1 0 1 0 NOT A 1 0 0 1 0 1 0 0 The bitwise AND, OR, and XOR operators can also be used with boolean expressions, as Boolean values effectively only contain one bit that is either true or false. This can be implemented in Java as follows: boolean musicOn = true; boolean televisionOn = true; boolean areBothOn = musicOn & televisionOn; // true boolean areAnyOn = musicOn | televisionOn; // true boolean isOnlyOneOn = musicOn ^ televisionOn; // false There are also assignment operators for these three bitwise operators, as shown in the following table. Operator Description &= Bitwise AND assignment |= Bitwise inclusive-OR assignment ^= Bitwise exclusive-XOR assignment ....
Invocation Chaining (01/03/2008)
...valueOf(i).charAt(0); System.out.println(firstChar); // prints 7 also It's quite easy to see how this works. The ....
Regular Expressions in Java (01/02/2008)
...tter" and wanted to test this against a string. String str1 = new String("better"); String str2 = new String("butter"); String regex = "b.tter"; str1.matches(regex); // returns true str2.matches(regex); // returns true In this case, matches on both string values will be found as the "....
Character Escape Sequences (12/29/2007)
... ........
Conditional Statements (12/29/2007)
...........
Java Methods (12/29/2007)
... The following line of code could be added, for example, in your main method to assign this value to a variable: int myNumber = getFiveDoubled(); This line of code will assign the value of 10 to the variable myNumber. Note Just because the method getFiveDoubled now has a return type, it does not mean that it cannot be called on its own. getFiveDoubled(); This method will essentially do nothing, but you may have a method that performs a required task and then returns a value, which you want to ignore. A method that has a return value (not void) must have a return statement at every possible exit point from the method. The compiler will pick up if a path without a return value is possible....
Variable Scope (12/29/2007)
...out.println("counter = " + counter); } System.out.println("counter final value = " + counter); Here we simply declare the variable counter before the for loop and then use it with the for loop in the same way but this time we do not declare it at the first stage of the for loop. Later, outside of the for loop code block, we can still access the variable counter because it has been declared within the scope of this area....
What is a Java Package (12/24/2007)
...io The I/O package contains classes that allow support for input and output operations. java.awt This is the Abstract Window Toolkit package and contains all the necessary classes to create a GUI within your Java applications and applets. java.awt....
Importing Java Packages (12/12/2007)
... Another example of this would be if we wished to include the utility package, which is called java.util. This would be done with the following statement: import java.util.*; Again, note the use of the asterisk to include all the classes from the package....

Go to Page# 1 2
A Strategy for Defining Immutable Objects in a Java application - The following rules define a simple strategy for creating immutable objects. Not all classes documented as "immutable" follow these rules. This does not necessarily mean the creators o (more...)
The Three Kinds of Exceptions in Java applications - An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions. When an error occurs within a method, the method crea (more...)
How to use the PATH and CLASSPATH environment variables on Windows Solaris and Linux - This section explains how to use the PATH and CLASSPATH environment variables on Microsoft Windows, Solaris, and Linux. Consult the installation instructions included with your installation o (more...)
Reasons to Write a Custom Collection Implementation in JAVA - Many programmers will never need to implement their own Collections classes. Someday you might want to write your own implementation. It is fairly easy to do this with the aid of the abstract (more...)
How to create a JAR File - The basic format of the command for creating a JAR file is: jar cf jar-file input-file(s) The options and arguments used in this command are: (more...)
What Is a Java Object ~ Advantages of bundling code into individual software objects - Objects are key to understanding object-oriented technology. Look around right now and you'll find many examples of real-world objects: your dog, your desk, your television set, your bicycle. (more...)
Processes and Threads in Java programming language - In concurrent programming, there are two basic units of execution: processes and threads. In the Java programming language, concurrent programming is mostly concerned with threads. However, pro (more...)
Steps to follow when writing a custom implementation - The process of writing a custom implementation follows: 1. Choose the appropriate abstract implementation class from the preceding list. 2. Provide implementations for (more...)
How to create view extract and update a JAR file archive - Creating a JAR File The basic format of the command for creating a JAR file is: jar cf jar-file input-file(s) The options and arguments used in this command are: (more...)
What Is Swing - To create a Java program with a graphical user interface (GUI), you'll want to learn about Swing. The Swing toolkit includes a rich set of components for building GUIs and adding intera (more...)
Benefits of the Java Collections Framework - A collections framework is a unified architecture for representing and manipulating collections. All collections frameworks contain the following: Interfaces These are abstract dat (more...)
Common Java Applet Problems - This tutorial covers some common problems that you might encounter when writing Java applets. After each problem there is a list of possible solutions. Problem: Applet Viewer say (more...)

 
free content
    Copyright © 2006 - 2012 e-articles.info.
The texts, articles and tutorials in the directory are property of their respective owners and authors.