Join
Blogs
Questions
Videos
Tags
Members
Search
 
 
Create your own blog, earn points and get popular!

Blogs

Andr's picture

Second Form of Assertion

0
Your rating: None
Second form of Assertion

The second for of assertion takes another expression as an argument.

The syntax is,

assert expression1 : expression2;

where expression1 is the condition and must evaluate to true at runtime.

This statement is equivalent to
Andr's picture

Enable Java Assertion

0
Your rating: None
Enabling Or Disabling Assertion

By default assertion is not enabled, but compiler complains if assert is used as an identifier or label. The following command will compile AssertionDemo example with assertion enabled.

javac –source 1.4 AssertionDemo.java

The resulting AssertionDemo class file will contain assertion code.
Andr's picture

Java Assertion, Java Assertion Classes

2
Your rating: None Average: 2 (1 vote)
Java Assertion Assertion facility is added in J2SE 1.4. In order to support this facility J2SE 1.4 added the keyword assert to the language, and AssertionError class. An assertion checks a boolean-typed expression that must be true during program runtime execution. The assertion facility can be enabled or disable at runtime.
Andr's picture

String Length, String Changing Case, String Intern, Java String Tutorial

5
Your rating: None Average: 5 (1 vote)
String Manipulation Part 3

6.) Manipulating Character Case

String class provides following methods to manipulate character case in String.

String toUpperCase()
String toUpperCase(Locale locale)

String toLowerCase()
String toLowerCase(Locale locale)
Andr's picture

Substring, Replace Characters From String, String Conversion, Java String Tutorial

0
Your rating: None
String Manipulation - Part 2

3.) Replacing characters in String

The replace method of String can be used to replace all occurrences of the specified character with given character.

String replace(char oldChar, int newchar)


4.) Getting substrings
Andr's picture

Java Search String, Reading Character From String, Java String Tutorial

0
Your rating: None
String Manipulation

1.) Reading characters from String:

char charAt(index i)

Returns char at specified index. An index ranges from 0 to length() -1.

2.) Searching characters in String
Andr's picture

String Equality, Compare Java Strings

0
Your rating: None
String equality - Compare Java String

String class overrides the equals() method of the Object class. It compares the content of the two string object and returns the boolean value accordingly.

For example,

String str1="Hello";
String str2="Hello";
Andr's picture

String Constructors

0
Your rating: None
String Constructors

String class provides various types of constructors to create String objects. Some of them are,

String()
Creates a new String object whose content is empty i.e. "".
Andr's picture

Java String, Java String Class

1
Your rating: None Average: 1 (1 vote)
Handling character strings in Java is supported through two final classes: String class and StringBuffer class. The Java String class implements immutable character strings, which are read-only once the string has been created and initialized, whereas the StringBuffer class implements dynamic character strings.
Andr's picture

Java SimpleDateFormat Example

2.625
Your rating: None Average: 2.6 (8 votes)
  1. /*
  2. Java SimpleDateFormat example.
  3. This Java SimpleDateFormat example describes how class is defined
  4. and being used in Java language.
  5.  
  6. */
  7.  
  8. import java.text.SimpleDateFormat;
  9. import java.util.Date;
  10.  
  11. public class JavaSimpleDateFormatExample{
  12.    
  13.     public static void main(String args[]){
  14.        
  15.         // Create Date object        
  16.         Date date = new Date();
  17.        
  18.  
Syndicate content