Location: Online
Schedule: http://code.google.com/codejam/africa_arabia/schedule.html
More details: http://code.google.com/codejam/africa_arabia
Source
Topics concerning technology in general, including techniques, tools, miscellaneous articles, etc.
Posted by
Yasser Talat
at
12:00 AM
0
comments
Posted by
Yasser Talat
at
4:27 PM
0
comments
Java Developer Conference 2010
I think this year's JDC will be so great and so interesting.
Do not miss the chance to attend.
Posted by
Yasser Talat
at
11:30 AM
0
comments
I tried the " Programmer Personality Type" test and following is my detailed result:
Your programmer personality type is:
PHTB
You're a Planner.
You may be slow, but you'll usually find the best solution. If something's worth doing, it's worth doing right.
You like coding at a High level.
The world is made up of objects and components, you should create your programs in the same way.
You work best in a Team.
A good group is better than the sum of it's parts. The only thing better than a genius programmer is a cohesive group of genius programmers.
You are a liBeral programmer.
Programming is a complex task and you should use white space and comments as freely as possible to help simplify the task. We're not writing on paper anymore so we can take up as much room as we need.
To try the test yourself, go to the following link:
Programmer Personality Test
Good Luck
Posted by
Yasser Talat
at
8:19 AM
3
comments
Many people are working with web services. Thus, web services is an evolving field that always has new terchnologies and/or APIs to support and ease the way to developing and using web services.
Posted by
Yasser Talat
at
12:17 AM
0
comments
Have you used the Database keyword "SAVEPOINT" before? Have you used it within Java?
First of all, I would like to give a brief definition and description for "SAVEPOINT".
"A savepoint is a way of implementing subtransactions (also known as nested transactions) within a relational database management system by indicating a point within a transaction that can be "rolled back to" without affecting any work done in the transaction before the savepoint was created. Multiple savepoints can exist within a single transaction. Savepoints are useful for implementing complex error recovery in database applications — if an error occurs in the midst of a multiple-statement transaction, the application may be able to recover from the error (by rolling back to a savepoint) without needing to abort the entire transaction.
A savepoint can be declared by issuing a SAVEPOINT name statement. All changes made after a savepoint has been declared can be undone by issuing a ROLLBACK TO SAVEPOINT name command. Issuing RELEASE SAVEPOINT name will cause the named savepoint to be discarded, but will not otherwise affect anything. Issuing the commands ROLLBACK or COMMIT will also discard any savepoints created since the start of the main transaction.
Savepoints are supported in some form or other in database systems like PostgreSQL, Oracle, Microsoft SQL Server, MySQL, DB2, and Firebird. Savepoints are also defined in the SQL standard."
This definition is quoted from wikipedia.
Posted by
Yasser Talat
at
2:18 PM
1 comments
Today, I am going to introduce one of the Java Technical Tips that I have previously received from sun on my e-mail. I wanted to share it with you . I hope every one who reads this tip will get benefit from.
The author of this tip is John Zukowski, president and principal consultant of JZ Ventures, Inc.
This tip was developed using Java SE 6.
Using Enhanced For-Loops with Your Classes
The enhanced for-loop is a popular feature introduced with the Java SE platform in version 5.0. Its simple structure allows one to simplify code by presenting for-loops that visit each element of an array/collection without explicitly expressing how one goes from element to element.
Because the old style of coding didn't become invalid with the new for-loop syntax, you don't have to use an enhanced for-loop when visiting each element of an array/collection. However, with the new style, one's code would typically change from something like the following:
for (int i=0; i System.out.println("Element: " + array[i]);}to the newer form:for (String element : array) { System.out.println("Element: " + element);}
Assuming "array" is defined to be an array of String objects, each element is assigned to the element variable as it loops through the array. These basics of the enhanced for-loop were covered in an earlier Tech Tip: The Enhanced For Loop, from May 5, 2005.
If you have a class called Colony which contains a group of Penguin objects, without doing anything extra to get the enhanced for-loop to work, one way you would loop through each penguin element would be to return an Iterator and iterate through the colony. Unfortunately, the enhanced for-loop does not work with Iterator , so the following won't even compile:
// Does not compileimport java.util.*;public class BadColony { static class Penguin { String name; Penguin(String name) { this.name = name; } public String toString() { return "Penguin{" + name + "}"; } } Set set = new HashSet(); public void addPenguin(Penguin p) { set.add(p); } public Iterator getPenguins() { return set.iterator(); } public static void main(String args[]) { Colony colony = new Colony(); Penguin opus = new Penguin("Opus"); Penguin chilly = new Penguin("Chilly Willy"); Penguin mumble = new Penguin("Mumble"); Penguin emperor = new Penguin("Emperor"); colony.addPenguin(opus); colony.addPenguin(chilly); colony.addPenguin(mumble); colony.addPenguin(emperor); Iterator it = colony.getPenguins(); // The bad line of code: for (Penguin p : it) { System.out.println(p); } }} You cannot just pass an Iterator into the enhanced for-loop. The 2nd line of the following will generate a compilation error:
Iterator it = colony.getPenguins(); for (Penguin p : it) {BadColony.java:36: foreach not applicable to expression type for (Penguin p : it) { ^1 error In order to be able to use your class with an enhanced for-loop, it does need an Iterator , but that Iterator must be provided via the Iterable interface:
public interface java.lang.Iterable { public java.util.Iterator iterator();} Actually, to be more correct, you can use a generic T , allowing the enhanced for-loop to avoid casting, returning the designated generic type, instead of just a plain old Object .
public interface java.lang.Iterable { public java.util.Iterator iterator(); } It is this Iterable object which is then provided to the enhanced for-loop. By making the Colony class implement Iterable , and having its new iterator()Iterator that getPenguins() provides, you'll be able to loop through the penguins in the colony via an enhanced for-loop. method return the
By adding the proper implements clause:
public class Colony implements Iterable { for (Penguin p : colony) {Here's the updated Colony class with the corrected code:import java.util.*;public class Colony implements static class Penguin { String name; Penguin(String name) { this.name = name; } public String toString() { return "Penguin{" + name } } Set public void addPenguin set.add(p); } public Iterator return set.iterator(); } public Iterator return getPenguins(); } public static void main Colony colony = new Colony Penguin opus = new Penguin Penguin chilly = new Penguin mumble = new Penguin emperor = new colony.addPenguin(opus); colony.addPenguin(chilly); colony.addPenguin(mumble); colony.addPenguin(emperor); for (Penguin p : colony) { System.out.println(p); } }}Running the code produces the > java Colony Penguin{Chilly Willy} Penguin{Mumble} Penguin{Opus} Penguin{Emperor}Keep in mind that the individual penguins are internally kept in a Set type collection so the returned order doesn't necessarily match the insertion order, which in this case it doesn't. Remember to genericize the implements clause for the class " With the latter, the enhanced for-loop will only return an each element. For more information on the enhanced for-loop, please see the |
Posted by
Yasser Talat
at
11:45 PM
0
comments