Monday, 29 February 2016
Java Tutorial : Java String(String pool)
Click here to watch in Youtube :
https://www.youtube.com/watch?v=hdgRaJ-G5DE&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java String(String pool) |
public class StringTest { public static void main(String[] args) { String s1 = "Cat"; String s2 = "Cat"; String s3 = "Dog"; String s4 = new String("Cat"); System.out.println("s1 == s2 : " + (s1 == s2)); System.out.println("s1 == s3 : " + (s1 == s3)); System.out.println("s1 == s3 : " + (s1 == s4)); } }
s1 == s2 : true s1 == s3 : false s1 == s3 : false
https://sites.google.com/site/javaee4321/java/StringDemo_StringPool_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/StringDemo_StringPool_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/ae1c81370f840697c745970d52d13d8987910b41/BasicJava/StringDemo_StringPool_App/?at=master
See also:
Java Tutorial : Java String(String Constant pool)
Click here to watch in Youtube :
https://www.youtube.com/watch?v=-NaDHpaIQX0&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java String(String Constant pool) |
public class StringTest { public static void main(String[] args) { String s1 = "Welcome"; String s2 = "Welcome";// will not create new instance System.out.println("s1 == s2 :"+(s1==s2)); } }
s1 == s2 :true
https://sites.google.com/site/javaee4321/java/StringDemo_StringConstantPool_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/StringDemo_StringConstantPool_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/ae1c81370f840697c745970d52d13d8987910b41/BasicJava/StringDemo_StringConstantPool_App/?at=master
See also:
Java Tutorial : Java String(How to create String Object)
Click here to watch in Youtube :
https://www.youtube.com/watch?v=ZYvzzTj-cJM&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java String(How to create String Object) |
Java Tutorial : Java String(How to create String Object) |
Java Tutorial : Java String(How to create String Object) |
public class StringTest { public static void main(String[] args) { String greeting = "Hello world"; System.out.println("greeting = " + greeting); char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.' }; String helloString = new String(helloArray); System.out.println("helloString = " + helloString); String welcomeString = new String("Welcome"); System.out.println("welcomeString = " + welcomeString); } }
greeting = Hello world helloString = hello. welcomeString = Welcome
Refer:
https://docs.oracle.com/javase/8/docs/api/index.html?java/lang/String.html
https://sites.google.com/site/javaee4321/java/StringDemo_How%20to%20Create_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/StringDemo_How%20to%20Create_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/ae1c81370f840697c745970d52d13d8987910b41/BasicJava/StringDemo_How%20to%20Create_App/?at=master
See also:
Friday, 26 February 2016
Java Tutorial : Java String(What is an immutable object)
Click here to watch in Youtube :
https://www.youtube.com/watch?v=tOESavjFzxA&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java String(What is an immutable object) |
/* * Person is an immutable class. Person's * state cannot be changed once it is created. * * We can't subclass the final class and * alter the behavior. */ public final class Person { final String name; public Person(String name) { this.name = name; } public String getName() { return name; } }
public class ImmutableTest { public static void main(String[] args) { Person personObj = new Person("Peter"); System.out.println(personObj.name); System.out.println(personObj.getName()); //personObj.name = "Dave"; } }
Peter Peter
https://sites.google.com/site/javaee4321/java/StringDemo_Immutable_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/StringDemo_Immutable_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/ec3cefb1e3f2c8e99780d56182501ac13735f589/BasicJava/StringDemo_Immutable_App/?at=master
See also:
Thursday, 25 February 2016
Java Tutorial : Java String
Click here to watch in Youtube :
https://www.youtube.com/watch?v=2eYgQcUsCc4&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java String |
Java Tutorial : Java String |
See also:
Java Tutorial : Java wrapper class (Character - escape sequences)
Click here to watch in Youtube :
https://www.youtube.com/watch?v=cZdmZ8W9c7k&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java wrapper class (Character - escape sequences) |
Java Tutorial : Java wrapper class (Character - escape sequences) |
public class EscapeSequenceTest { public static void main(String[] args) { System.out.println("\t he said \"Hello!\" to me.\n"); System.out.println("\'Welcome\\"); } }
he said "Hello!" to me. 'Welcome\
https://sites.google.com/site/javaee4321/java/EscapeSequenceDemo_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/EscapeSequenceDemo_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/f04fb0b510d935a99056b97ab2ac51f619fac410/BasicJava/EscapeSequenceDemo_App/?at=master
See also:
Java Tutorial : Java wrapper class (Character class methods)
Click here to watch in Youtube :
https://www.youtube.com/watch?v=-Y2au3fZtp4&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java wrapper class (Character class methods) |
public class WrapperClassTest { public static void main(String[] args) { /* * Determines whether the specified char value is a * letter. */ boolean isLetter = Character.isLetter('a'); System.out.println("Character.isLetter('a') = " + isLetter); /* * Determines whether the specified char value is a * digit. */ boolean isDigit = Character.isDigit('2'); System.out.println("Character.isDigit('2') = " + isDigit); /* * Determines whether the specified char value is * white space. */ boolean isWhiteSpace = Character.isWhitespace(' '); System.out.println("Character.isWhitespace(' ') = " + isWhiteSpace); /* * Determines whether the specified char value is * uppercase. */ boolean isUpperCase = Character.isUpperCase('A'); System.out.println("Character.isUpperCase('A') = " + isUpperCase); /* * * Determines whether the specified char value is * lowercase. */ boolean isLowerCase = Character.isLowerCase('a'); System.out.println("Character.isLowerCase('a') = " + isLowerCase); /* * Returns the uppercase form of the specified char * value. */ System.out.println("Character.toUpperCase('m') = " + Character.toUpperCase('m')); /* * Returns the lowercase form of the specified char * value. */ System.out.println("Character.toLowerCase('B') = " + Character.toLowerCase('B')); /* * Returns a String object representing the * specified character value — that is, a * one-character string. */ String str = Character.toString('u'); System.out.println("Character.toString('u') = " + str); } }Output
Character.isLetter('a') = true Character.isDigit('2') = true Character.isWhitespace(' ') = true Character.isUpperCase('A') = true Character.isLowerCase('a') = true Character.toUpperCase('m') = M Character.toLowerCase('B') = b Character.toString('u') = uRefer:
https://docs.oracle.com/javase/8/docs/api/index.html?java/lang/Character.html
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/WrapperClassDemo_Character_methods_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/WrapperClassDemo_Character_methods_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/f04fb0b510d935a99056b97ab2ac51f619fac410/BasicJava/WrapperClassDemo_Character_methods_App/?at=master
See also:
Tuesday, 23 February 2016
Java Tutorial : Java wrapper class (Character)
Click here to watch in Youtube :
https://www.youtube.com/watch?v=uHHb0bm0zVU&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java wrapper class (Character) |
Java Tutorial : Java wrapper class (Character) |
public class WrapperClassTest { public static void main(String[] args) { char ch = 'a'; System.out.println("ch = " + ch); Character characterObj = new Character(ch); System.out.println("characterObj = " + characterObj); /* * If you pass a primitive char into a method that * expects an object, the compiler automatically * converts the char to a Character for you.This * feature is called autoboxing. */ displayCharObj('c'); /* * If you pass an object into a method that expects * an primitive char, the compiler automatically * converts the Character to a char for you.This * feature is called unboxing. */ displayChar(new Character('z')); } public static void displayCharObj(Character characterObjParam) { System.out .println("characterObjParam = " + characterObjParam); } public static void displayChar(char chParam) { System.out.println("chParam = " + chParam); } }
ch = a characterObj = a characterObjParam = c chParam = z
https://sites.google.com/site/javaee4321/java/WrapperClassDemo_Character_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/WrapperClassDemo_Character_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/9880b82016e29094f797cfa7ceb03441b567b426/BasicJava/WrapperClassDemo_Character_App/?at=master
See also:
Java Tutorial : Java format (DecimalFormat class)
Click here to watch in Youtube :
https://www.youtube.com/watch?v=SiPUuR5UQpU&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java format (DecimalFormat class) |
Java Tutorial : Java format (DecimalFormat class) |
import java.text.DecimalFormat; public class DecimalFormatDemo { static public void customFormat(String pattern, double value) { DecimalFormat myFormatter = new DecimalFormat(pattern); String output = myFormatter.format(value); System.out.println(value + " " + pattern + " " + output); } static public void main(String[] args) { customFormat("###,###.###", 123456.789); customFormat("###.##", 123456.789); customFormat("000000.000", 123.78); customFormat("$###,###.###", 12345.67); } }
123456.789 ###,###.### 123,456.789 123456.789 ###.## 123456.79 123.78 000000.000 000123.780 12345.67 $###,###.### $12,345.67
https://sites.google.com/site/javaee4321/java/FormatDemo_DecimalFormat_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/FormatDemo_DecimalFormat_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/9880b82016e29094f797cfa7ceb03441b567b426/BasicJava/FormatDemo_DecimalFormat_App/?at=master
See also:
Monday, 22 February 2016
Java Tutorial : Java format and printf methods(Converters and flags)
Click here to watch in Youtube :
https://www.youtube.com/watch?v=4lyH3QaOVgA&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java format and printf methods(Converters and flags) |
Java Tutorial : Java format and printf methods(Converters and flags) |
import java.util.Calendar; import java.util.Locale; public class FormatNumericExample { public static void main(String[] args) { long n = 461012; System.out.format("%d%n", n); // --> "461012" System.out.format("%08d%n", n); // --> "00461012" System.out.format("%+8d%n", n); // --> " +461012" System.out.format("%,8d%n", n); // --> " 461,012" System.out.format("%+,8d%n%n", n); // --> "+461,012" double pi = Math.PI; System.out.format("%f%n", pi); // --> "3.141593" System.out.format("%.3f%n", pi); // --> "3.142" System.out.format("%10.3f%n", pi); // --> // " 3.142" System.out.format("%-10.3f%n", pi); // --> "3.142" System.out.format(Locale.FRANCE, "%-10.4f%n%n", pi); // --> // "3,1416" Calendar c = Calendar.getInstance(); System.out.format("%tB %te, %tY%n", c, c, c); // --> // "May 29, 2006" System.out.format("%tl:%tM %tp%n", c, c, c); // --> // "2:34 am" System.out.format("%tD%n", c); // --> "05/29/06" } }
461012 00461012 +461012 461,012 +461,012 3.141593 3.142 3.142 3.142 3,1416 February 22, 2016 12:08 pm 02/22/16
https://sites.google.com/site/javaee4321/java/FormatDemo_format_Converters_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/FormatDemo_format_Converters_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/d0559102086f9677d57877fbba43556aca45fc19/BasicJava/FormatDemo_format_Converters_App/?at=master
See also:
Java Tutorial : Java format and printf methods
Click here to watch in Youtube :
https://www.youtube.com/watch?v=B9T6PDXwXeE&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java format and printf methods |
Java Tutorial : Java format and printf methods |
public class FormatNumericExample { public static void main(String[] args) { System.out.format("%s, %s", "Hello", "world"); System.out.println("\n---------------------------"); float floatVar = 90.8f; int intVar = 100; String stringVar = "Peter"; System.out .format("The value of the float variable is " + "%f, while the value of the integer variable is %d, " + "and the string is %s", floatVar, intVar, stringVar); } }
Hello, world --------------------------- The value of the float variable is 90.800003, while the value of the integer variable is 100, and the string is Peter
public class PrintfNumericExample { public static void main(String[] args) { System.out.printf("%s, %s", "Hello", "world"); System.out.println("\n---------------------------"); float floatVar = 90.8f; int intVar = 100; String stringVar = "Peter"; System.out .printf("The value of the float variable is " + "%f, while the value of the integer variable is %d, " + "and the string is %s", floatVar, intVar, stringVar); } }
Hello, world --------------------------- The value of the float variable is 90.800003, while the value of the integer variable is 100, and the string is Peter
https://sites.google.com/site/javaee4321/java/FormatDemo_format_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/FormatDemo_format_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/d0559102086f9677d57877fbba43556aca45fc19/BasicJava/FormatDemo_format_App/?at=master
See also: