This collapsible list was developed using jQuery. (And this font was created using Google Web Fonts.)
selector {property: value; property: value; ... }
person.name person['name'] var n = name; person[n];
var person = new Object(); person.name = 'Puneet'; person.location = 'Boston';
var person = { name: 'Puneet', location: 'Boston' };
If you have a function f and an object o, you can define a method m as follows (note that the parentheses after f are omitted because we want to assign the function (i.e. create a reference to the function) rather than invoke it and assign the return value):
o.m = f;
Method m may then be invoked as follows:
o.m();
In the body of method m, the object o (i.e. m's invocation context, aka function context) may be referenced via the keyword this
function square(x) {return x*x;}
var square = function(x) {return x*x;}
(function() { //do something })();
window.foo = value;
=== and !== == and !=
var javascriptObjectRepresentation = JSON.parse(jsonStringRepresentation);
To do the reverse:
var jsonStringRepresentation = JSON.stringify(javascriptObjectRepresentation);
function name(value){ //setter if(value){ this.name=value; } //getter return this.name; }
Obj obj = new Obj(); do(obj); void do(Obj objArg) { ... }
public class IntMessageQueueOfCapacityOne { private int contents; private boolean available = false; public synchronized int get() { while (available == false) { try { wait(); } catch (InterruptedException e) { } } available = false; notifyAll(); return contents; } public synchronized void put(int value) { while (available == true) { try { wait(); } catch (InterruptedException e) { } } contents = value; available = true; notifyAll(); } }
java [-options] class [arguments] or java [-options] -jar jarfile [arguments]
Main-Class: classname
http://stackoverflow.com/questions/1673841/examples-of-gof-design-patterns http://www.briandupreez.net/2010/11/design-patterns-in-jdk.html
/* Assume that Circle and Triangle are subclasses of Shape */ Circle c = new Circle(); Triangle t = new Triangle(); /* Here, instances of Circle and Triangle are being upcasted to Shape */ Shape[] shapes = {c, t}; /* In the following snippet of Java code, Java does not know at compile time whether shapes[i] is an instance of Circle or Triangle Polymorphism ensures that Java does not *need* to know this statically, i.e. at compile time Obviously, calculateArea() will be implemented differently by the subclasses of Shape, i.e. Circle, Triangle, etc. However, the compiler does not need to check what subtype of Shape it is dealing with and bind to the method of the appropriate subclass, i.e., Circle.calculateArea(), Triangle.calculateArea(), etc. Instead, Java will automatically determine at runtime that shapes[1] is an instance of Triangle and use dynamic binding (also known as late binding or runtime type identification RTTI) to bind the method call to Triangle.calculateArea() Since every sublclass of Shape has the ability to calculate its area, this program invokes Shape.calculateArea() without worrying about the specific subclass at hand Thus, polymorphism allows the following code to be more extensible since it will not impacted when new subclasses are added to the Shape hierarchy */ for (int i = 0; i < count; i++) { System.out.println(shapes[i].calculateArea()); }
<%@ include file="copyright.inc"%>
<jsp:include page="copyright.inc"/>
<tagName attributeName="attributeValue"/>
<tagName attributeName="attributeValue">content</tagName>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:forEach>
http://mycompany.com/getProduct?productId=1234
<jsp:useBean id="myBean" scope="request" class="myBeanClass">
<jsp:getProperty> <jsp:setProperty>
log4j.rootLogger=DEBUG, myLogFile
log4j.appender.myLogFile=org.apache.log4j.RollingFileAppender
log4j.appender.myLogFile=mylog.log
log4j.appender.myLogFile.threshold=WARN