Professional Documents
Culture Documents
import com.abc.transport.Car;
// need to import classes in other packages
public class Travel{
public static void main (String[] args) {
Car c = new Car();
c.setType("Audi");
System.out.println("My car is : "+ c.getType());
}
}
package com.abc.transport;
// class Car is placed in package
public class Car extends Vehicle {
} Access specifiers:
//Compile : javac d . *.java
All private members can be
accessed by the same class
only
All protected members can be
accessed by same, child class
and classes in same package
All default members can be
accessed by same and
classes in same package
All public members can be
accessed by all classes in any
package
To print an object,
System.out.println(obj);
com.abc.transport.Car@110b053
Car is Audi
The method
.equals(Object obj)
public Employee () {
this.location = Bangalore;
this.location = location;
new Employee(Mumbai);
st2.str = "Delhi";
Output is :
st1.str :Bangalore
System.out.println("sbf = "+sbf);
cs.updateMe(str);
System.out.println("str = "+str);
cs.updateMe(sbf);
System.out.println("now sbf = "+sbf);
sbf.append(" - Bangalore");
String passwordPattern =
"^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%^&+=])(?=\\S+$).{8,}$;
^ start of line
$ end of line
System.out.println(matcher.matches());
^ start of line
[_A-Za-z0-9-\\+]+ must start with string in the bracket AND must contain one or
more of the string
(\\.[_A-Za-z0-9-]+)* follow by a period '.' AND string in the bracket one or more AND is
optional
@[A-Za-z0-9-]+ must contain a '@' followed by string in the bracket one or more
(\\.[A-Za-z0-9]+)* follow by a period '.' AND string in the bracket one or more AND is
optional
(\\.[A-Za-z]{2,}) follow by a period '.' AND string in the bracket at least 2 characters
$ end of line
At +91 9916482106.