Javier Neira's Library tagged → View Popular
def groovy: Delivering Business Value Through Polyglot Systems (part 1)
-
In retrospect I don't think Groovy fits into my concerns about Polyglotism. For one it is a superset of Java. It also uses the same class libraries as a Java applicati
Java is Pass-by-Value, Dammit! - Scott Stanchfield
-
In Java, Objects are
passed by reference, and primitives are passed by value. -
However,
Objects are not passed by reference. A correct statement would be
Object references are passed by value. - 3 more annotations...
PreciseJava.com - Best practices to improve performance in JDBC
-
You can send multiple queries to the database at a time using batch update
feature of statement objects this reduces the number of JDBC calls and improves
performance. Here is an example of how you can do batch update,statement.addBatch( "sql query1");
statement.addBatch(" sql query2");
statement.addBatch(" sql query3");
statement.executeBatch();
All three types of statements have these methods to do batch update.
Working with Java Enumerated types (Enums) « Java PitStop
01 enum Speed{
02 LOW(3,2.5){ //Line 1
03 String getInformation(){ //Method overriden by the Enum constants
04 return "Running of Low speed with less units consumed";
05 }
06 },
07 MEDIUM(6,5.0){ //Line 2
08 String getInformation(){
09 return "Running of Medium speed with moderate units consumed";
10 }
11 },
12 HIGH(10,7.5){ //Line 3
13 String getInformation(){
14 return "Running of High speed with Maximum units consumed";
15 }
16 };
17 private int speedValue;
18 private double unitsConsumed;
19 Speed(int speed, double units){
20 this.speedValue=speed;
21 this.unitsConsumed=units;
22 }
23 public int getSpeedValue(){
24 return this.speedValue;
25 }
26 public double getUnitsConsumed(){
27 return this.unitsConsumed;
28 }
29 abstract String getInformation(); //This is an abstract method
30 }
31 public class Machine{
32 Speed machineSpeed;
33 Machine(Speed speed){
34 this.machineSpeed=speed;
35 }
36 Speed getSpeed(){
37 return this.machineSpeed;
38 }
39 public static void main(String[] args){
40 Machine machine1 = new Machine(Speed.LOW);
41 Machine machine2 = new Machine(Speed.HIGH);
42 System.out.println("Machine 1 speed: "+machine1.getSpeed().getInformation());
43 System.out.println("Machine 2 speed: "+machine2.getSpeed().getInformation());
44 }
45 }
Configuring and using XA distributed transactions in WebSphere Studio
This article describes distributed transactions and shows you how to configure a WebSphere Studio Application Developer test server with XA resources for DB2, Oracle, and JMS that can be used together in a distributed transaction. The article describes an
-
While all of these features are useful, perhaps the single greatest advantage of using EJBs is
transaction management. EJBs and container-managed transactions (CMTs) make transaction management virtually transparent to the bean developer. -
The container infers the transaction model
from the method boundaries and deployment descriptor, and controls the transaction commits and rollbacks at runtime. - 1 more annotations...
jna: Java Native Access (JNA): Pure Java access to native libraries
JNA provides Java programs easy access to native shared libraries (DLLs on Windows) without writing anything but Java code—no JNI or native code is required. This functionality is comparable to Windows' Platform/Invoke and Python's ctypes. Access is dynamic at runtime without code generation.
Why extension methods are evil ? | Java.net
-
As you may already know, I'm a big fan of closures but the introduction of
extension methods in Java really scary me. -
An extension method is a static method but with a special syntax to
differentiate them from static method. Because the syntax is not important, I
use a new keyword, extension that can be used instead of static. This allow to
retrofit already existing static method to an extension method. - 4 more annotations...
Poll Result: Majority Supports Including Closures in Java 7 | Java.net
-
14% (50 votes) - Where was the community process in this decision?
-
"Closures are coming. Our closures. Applaud. Now".
JavaBlogging » Dynamic in-memory compilation
Let’s suppose you have some string containing a source code for a class, something like “public class Test {}”. You want to compile it dynamically in memory and get an instance of that class. How can you accomplish that? We will try to present here a way to do it. We will use the javax.tools package that was added in Java 6, so be sure that you are using Java 6 or later to run the codes.
-
After we define it, we print it to the console, get an instance of the compiler, put the source code into an object representing a source file, create a file manager and a compilation task. The real compilation starts when we call the call() method of the compilation task. Then we get the Class representing our compiled class from the file manager, instantiate our class and print it to the console, using the toString() function that we implemented in the code.
-
There are three classes used in the code that are not available in the JDK and hence we have to implement them by ourselves – CharSequenceJavaFileObject, JavaClassObject and ClassFileManger. Let’s see them one by one to understand what they are doing.
- 4 more annotations...
[JavaSpecialists 018] - Class names don't identify a class
-
It is entirely feasible
that you have two developers with different versions of classes
deploying their applications onto the same server. You don't
necessarily want to start a new VM for each deployment, and so
with ClassLoaders it is possible to have lots of classes with the
same name running in the same memory space but not conflicting
with one another. They would also share the common JDK classes
with one another, so we would not have to have a
java.util.ArrayList class loaded for each of the ClassLoaders.
Working in Java time - JavaWorld
1. Java reckons time in milliseconds before or after the start of January 1, 1970.
2. The Date class's constructor Date() returns an object that represents the moment the object was created. Date's getTime() method returns a long value whose number equals the number of milliseconds before or after January 1, 1970.
3. The DateFormat class is used to convert Dates to Strings, and vice versa. The static getDateInstance() method returns a DateFormat object in the default format; the getDateInstance(DateFormat.FIELD) returns a DateFormat object with a specified format. The format(Date d) method returns a String that represents the date, such as "January 1, 2002." Conversely, the parse(String s) method returns a Date object based on the date the String argument represents.
4. The appearance of Strings returned by the format() method can vary according to the regional settings on the computer where the program is being run.
5. The GregorianCalendar class has two important constructors: GregorianCalendar(), which returns an object that represents the moment it was created, and the GregorianCalendar(int year, int month, int date) constructor used to create an object that represents an arbitrary date. The GregorianCalendar class's getTime() method returns a Date object. The add(int field, int amount) method calculates dates by adding or subtracting units of time like days, months, or years.
-
- This article builds on the information presented in my Calculating Java Dates article (JavaWorld, December 29, 2000). Here I've listed some key points from that article that should be familiar to you. If these points are
- Java reckons time in milliseconds before or after the start of January 1, 1970.
- The
Dateclass's constructorDate()returns an object that represents the moment the object was created.Date'sgetTime()method returns alongvalue whose number equals the number of milliseconds before or after January 1, 1970.
- The
DateFormatclass is used to convertDates toStrings, and vice versa. The staticgetDateInstance()method returns aDateFormatobject in the default format; thegetDateInstance(DateFormat.FIELD)returns aDateFormatobject with a specified format. Theformat(Date d)method returns aStringthat represents the date, such as "January 1, 2002." Conversely, theparse(String s)method returns aDateobject based on the date theStringargument represents.
- The appearance of
Strings returned by theformat()method can vary according to the regional settings on the computer where the program is being run.
- The
GregorianCalendarclass has two important constructors:GregorianCalendar(), which returns an object that represents the moment it was created, and theGregorianCalendar(int year, int month, int date)constructor used to create an object that represents an arbitrary date. TheGregorianCalendarclass'sgetTime()method returns aDateobject. Theadd(int field, int amount)method calculates dates by adding or subtracting units of time like days, months, or years.
not clear to you, I recommend that you read "Calculating Java Dates" for further explanation.
InfoQ: Mark Reinhold on Closures for Java
-
Extension methods, so that closure-oriented bulk-data methods can be retrofitted onto existing libraries, and in particular the Collections Framework, without breaking compatibility.
-
Java is often criticised for the slow pace of its evolution.
- 1 more annotations...
Selected Tags
Related Tags
Sponsored Links
Top Contributors
Groups interested in java
-
Java and Java script Programind
Codes and techniques of pro...
Items: 4 | Visits: 113
Created by: stefan stoichev
-
Java
Items: 574 | Visits: 146
Created by: Lubos Pochman
Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »
Join Diigo
