| Refresh | Home EGTry.com

primitive data type from javascript to java



1. string and character

definition in javascript (host html page)

      var ch="a";
      var str="hello"


use in java

	
	public static native String ch() /*-{
		return $wnd.ch;
		}-*/;
	
	public static native String str() /*-{
		return $wnd.str;
		}-*/;



2. integer

definition in javascript (host html page)

      var int1=100;


use in java

	public static native int int1() /*-{
		return $wnd.int1;
	}-*/;



3. boolean

definition in javascript (host html page)

        var bool1=false;


use in java

	public static native boolean bool1() /*-{
		return $wnd.bool1;
		}-*/;



4. floating number

definition in javascript (host html page)

             var float1=3.14;


use in java

	public static native float float1() /*-{
		return $wnd.float1;
		}-*/;
	
	public static native double  double1() /*-{
		return $wnd.float1;
		}-*/;