String
var s1 = 'Hello';
var s2 = "Hello";
embed expression
def name = 'Joe';
var s = "Hello {name}"; // s = 'Hello Joe'
expression within expression
def answer = true;
var s = "The answer is {if (answer) "Yes" else "No"}"; // s = 'The answer is Yes'
join and concatenate
def one = "This example ";
def two = "joins two strings.";
def three = "{one}{two}"; // join string one and string two
println(three); // 'This example joins two strings.'
Number and Integer
def numOne = 1.0; // compiler will infer Number
def numTwo = 1; // compiler will infer Integer
explicit variable declaration
def numOne : Number = 1.0;
def numTwo : Integer = 1;
Boolean
var isAsleep = true;
Duration (TheDuration
type represents a fixed unit of time (millisecond, second, minute, or hour.))
5ms; // 5 milliseconds
10s; // 10 seconds
30m; // 30 minutes
1h; // 1 hour
Void and Null
function printMe() : Void {
println("I don't return anything!");
}
function checkArg(arg1: Address) {
if(arg1 == null) {
println("I received a null argument.");
} else {
println("The argument has a value.");
}
}
More of this here
Friday, June 19, 2009
JavaFX Datatypes
Sequencing in JavaFx
def weekDays = ["Mon","Tue","Wed","Thu","Fri"];
explicitly specifying sequence type
def weekDays: String[] = ["Mon","Tue","Wed","Thu","Fri"];
Sequence within Sequence
def days = [weekDays, ["Sat","Sun"]];
compiler treats this as
def days = ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];
shorhand notation for sequence
def nums = [1..100];
more of this in here
java fx at a glance
The JavaFX Script programming language lets you create modern looking applications with sophisticated graphical user interfaces. It was designed from the ground up to make GUI programming easy.
We will be declaring variables like
def a;
def b;
var ag;
calling the function like
add();
div();
function can be written as
function add(){
statement1 ;
statement 2;
}
passing parameter to the function as
function add(arg1: Integer, arg2: Integer){
statement1 ;
}
function with return statements
function add(arg1: Integer, arg2: Integer) : Integer{
statement1 ;
return result;
}
command line arguments
function add(arg: String[]){
def a = java.lang.Integer.parseInt(arg[0]);
def b = java.lang.Integer.parseInt(arg[1]);
}
Object is created by
We will be declaring variables like
def a;
def b;
var ag;
calling the function like
add();
div();
function can be written as
function add(){
statement1 ;
statement 2;
}
passing parameter to the function as
function add(arg1: Integer, arg2: Integer){
statement1 ;
}
function with return statements
function add(arg1: Integer, arg2: Integer) : Integer{
statement1 ;
return result;
}
command line arguments
function add(arg: String[]){
def a = java.lang.Integer.parseInt(arg[0]);
def b = java.lang.Integer.parseInt(arg[1]);
}
Object is created by
Address {
street: "1 Main Street";
city: "Santa Clara";
state: "CA";
zip: "95050";
}
assigning to a variable
def myAddress = Address {
street: "1 Main Street";
city: "Santa Clara";
state: "CA";
zip: "95050";
}
nesting object inside another
def customer = Customer {
firstName: "John";
lastName: "Doe";
phoneNum: "(408) 555-1212";
address: Address {
street: "1 Main Street";
city: "Santa Clara";
state: "CA";
zip: "95050";
}
instance function can be invoked by
customer.printName();
customer.printPhoneNum();
customer.printAddress();
Saturday, June 13, 2009
Best way to source control - Tortoise SVN
Hi Recently I heard about this source controlling software which is very light and easy to use..
Mapped to an online repository http://beanstalkapp.com/ now we are able to source control out projects on the move with all new , Tortoise SVN.
First, we need to create an empty folder and inside this we have to right click and say 'Create Repository here'
Now Click on the 'SVN checkout' and enter the host name for the repository and the checkout directory.
Now we will be connected to the repository.
After this we are allowed to access the online repository with all common source controlling options on the move.
Mapped to an online repository http://beanstalkapp.com/ now we are able to source control out projects on the move with all new , Tortoise SVN.
First, we need to create an empty folder and inside this we have to right click and say 'Create Repository here'
Now Click on the 'SVN checkout' and enter the host name for the repository and the checkout directory.
Now we will be connected to the repository.
After this we are allowed to access the online repository with all common source controlling options on the move.
Friday, June 12, 2009
Know some hashcodes
Some of the hashcodes of interest's are in java wrappers
Boolean - hashCode() - 1231 for 'true' and '1237' for 'false'
Integer - hashCode() - will return the primitive int value
Byte - hashCode() - primitive int value of the byte is returned as hashcode
Charater- hashCode() - primitive int value of the byte is returned as hashcode
Long - value of the following expression
(int)(this.longValue()^(this.longValue()>>>32))
Boolean - hashCode() - 1231 for 'true' and '1237' for 'false'
Integer - hashCode() - will return the primitive int value
Byte - hashCode() - primitive int value of the byte is returned as hashcode
Charater- hashCode() - primitive int value of the byte is returned as hashcode
Long - value of the following expression
(int)(this.longValue()^(this.longValue()>>>32))
Magic.. Magic..
Ever wonder how files are identified correctly as jpeg, gif or even class file for that matter by the OS.
Its all magic.. :)
Magic numbers are those which are prefixed at the start of the file in ASCII code to identify the file format.
Some of the common magic numbers are
Class bytecode starts with hex
GIF image files have 'GIF89a' (
JPEG image files begin with
PNG image files begin with "
ZIP files begin with 'PK' (
PDF files start with '%PDF' (
Its all magic.. :)
Magic numbers are those which are prefixed at the start of the file in ASCII code to identify the file format.
Some of the common magic numbers are
Class bytecode starts with hex
GIF image files have 'GIF89a' (
47
49
46
38
39
61
) or 'GIF87a' (47
49
46
38
37
61
)JPEG image files begin with
FF
D8
and end with FF
D9
PNG image files begin with "
\211
P
N
G
\r
\n
\032
\n
" (89
50
4E
47
0D
0A
1A
0A
)ZIP files begin with 'PK' (
50
4B
)PDF files start with '%PDF' (
25
50
44
46
)
Subscribe to:
Posts (Atom)