Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts
Job : Java Developer in Hyderabad
Capgemini company is looking for a Java Developer in Hyderabad location. The following are the details :

Company: Capgemini
Position: Java Developer
Qualifications: Any Bachelor’s degree
Experience: 4-9 years
Skillset:
- Strong Core Java and spring.
- Strong experience on Microservices and SpringBoot
- Strong RESTFUL web service experience
- Strong SQL (preferably Oracle), JQuery, HTML/CSS, Oracle Restful, SOAP web services
Apply: Apply Here
Hotel Program using OOPs Concepts in Java
/*
the Hotel is an ArrayList of Reservations
it allows a person to request a room and cancel their reservation
also we can add more rooms
*/
import java.util.ArrayList;
public class Hotel{
//instance variable, ArrayList tracks current reservations
private ArrayList<Reservation> rooms;
//constructors, can specify how many rooms to start with
//default is 5 rooms
public Hotel(){
rooms = new ArrayList<Reservation>();
rooms.ensureCapacity(5);
for (int i = 0; i < 5; i++)
rooms.add(null);
}
public Hotel(int numRooms){
rooms = new ArrayList();
rooms.ensureCapacity(numRooms);
for(int i = 0; i< numRooms; i++)
rooms.add(null);
}
//adds more rooms to the hotel, returns true on success
public boolean buildRooms(int num){
//make sure the parameter is valid
if(num<=0)return false;
//increase the capacity of the Vector
rooms.ensureCapacity(rooms.size() + num);
for(int i = 0; i < num; i++)
rooms.add(null);
//report succes
return true;
}
//reserves and returns an available room
//or returns -1 if the hotel is full
public int reserveRoom(String person) {
boolean emptyRoom = false;
int i = 0;
for ( i = 0; i < rooms.size(); i++) {
if (rooms.get(i) == null) {
emptyRoom = true;
break;
}
}
if (emptyRoom == true) {
Reservation customer = new Reservation(person,i);
//rooms.get(i) = customer;
rooms.set(i, customer);
return i;
}
return -1;
}
//reserves a particular room for this person
//returns false on failure (eg. room is already reserved)
public boolean reserveRoom(String person, int roomNum) {
if(rooms.get(roomNum) == null){
Reservation customer = new Reservation(person,roomNum);
rooms.set(roomNum, customer);
return true;
}
else {
return false;
}
}
//cancels all reservations by this person
public void cancelReservations(String person) {
for (int i = 0; i < rooms.size(); i++){
if (rooms.get(i)!=null){
if (rooms.get(i).getName().compareTo(person)==0) {
rooms.set(i, null);
}
}
}
}
//prints out all the current reservations to the screen
//also should display the total number of reservations and vacancies
public void printReservations() {
for (int i = 0; i< rooms.size(); i++ ) {
if (rooms.get(i)!=null){
System.out.println(rooms.get(i).getName() +"-room number->"+ rooms.get(i).getRoom());
}
}
}
}
........***
/*
Reservation class, stores the person and room number in the Hotel
*/
public class Reservation{
//instance variables
private String name;
private int roomNumber;
//constructors, must supply the name, and optionally a room
public Reservation(String person){
this.name = person;
}
public Reservation(String person, int room){
this.name = person;
this.roomNumber = room;
}
//mutators, set the room number or name
public void setRoom(int newroom){
roomNumber = newroom;
}
public void setName(String newname){
name = newname;
}
//accessors, return the room number or name
public int getRoom(){
return roomNumber;
}
public String getName(){
return name;
}
}
the Hotel is an ArrayList of Reservations
it allows a person to request a room and cancel their reservation
also we can add more rooms
*/
import java.util.ArrayList;
public class Hotel{
//instance variable, ArrayList tracks current reservations
private ArrayList<Reservation> rooms;
//constructors, can specify how many rooms to start with
//default is 5 rooms
public Hotel(){
rooms = new ArrayList<Reservation>();
rooms.ensureCapacity(5);
for (int i = 0; i < 5; i++)
rooms.add(null);
}
public Hotel(int numRooms){
rooms = new ArrayList();
rooms.ensureCapacity(numRooms);
for(int i = 0; i< numRooms; i++)
rooms.add(null);
}
//adds more rooms to the hotel, returns true on success
public boolean buildRooms(int num){
//make sure the parameter is valid
if(num<=0)return false;
//increase the capacity of the Vector
rooms.ensureCapacity(rooms.size() + num);
for(int i = 0; i < num; i++)
rooms.add(null);
//report succes
return true;
}
//reserves and returns an available room
//or returns -1 if the hotel is full
public int reserveRoom(String person) {
boolean emptyRoom = false;
int i = 0;
for ( i = 0; i < rooms.size(); i++) {
if (rooms.get(i) == null) {
emptyRoom = true;
break;
}
}
if (emptyRoom == true) {
Reservation customer = new Reservation(person,i);
//rooms.get(i) = customer;
rooms.set(i, customer);
return i;
}
return -1;
}
//reserves a particular room for this person
//returns false on failure (eg. room is already reserved)
public boolean reserveRoom(String person, int roomNum) {
if(rooms.get(roomNum) == null){
Reservation customer = new Reservation(person,roomNum);
rooms.set(roomNum, customer);
return true;
}
else {
return false;
}
}
//cancels all reservations by this person
public void cancelReservations(String person) {
for (int i = 0; i < rooms.size(); i++){
if (rooms.get(i)!=null){
if (rooms.get(i).getName().compareTo(person)==0) {
rooms.set(i, null);
}
}
}
}
//prints out all the current reservations to the screen
//also should display the total number of reservations and vacancies
public void printReservations() {
for (int i = 0; i< rooms.size(); i++ ) {
if (rooms.get(i)!=null){
System.out.println(rooms.get(i).getName() +"-room number->"+ rooms.get(i).getRoom());
}
}
}
}
........***
/*
Reservation class, stores the person and room number in the Hotel
*/
public class Reservation{
//instance variables
private String name;
private int roomNumber;
//constructors, must supply the name, and optionally a room
public Reservation(String person){
this.name = person;
}
public Reservation(String person, int room){
this.name = person;
this.roomNumber = room;
}
//mutators, set the room number or name
public void setRoom(int newroom){
roomNumber = newroom;
}
public void setName(String newname){
name = newname;
}
//accessors, return the room number or name
public int getRoom(){
return roomNumber;
}
public String getName(){
return name;
}
}
Differences between Set & List -Collections in java
Set:
Set does not allow duplicate values.
Set is an unordered collection.
Set implementations: HashSet, LinkedHashSet, TreeSet etc.
Set can have only a single null value at most.
List:
List is an ordered collection it maintains the insertion order
List allows duplicates
List implementations: ArrayList, LinkedList etc.
List allows any number of null values
Set does not allow duplicate values.
Set is an unordered collection.
Set implementations: HashSet, LinkedHashSet, TreeSet etc.
Set can have only a single null value at most.
List:
List is an ordered collection it maintains the insertion order
List allows duplicates
List implementations: ArrayList, LinkedList etc.
List allows any number of null values
History of Java - Java
- James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language project in June 1991. The small team of sun engineers called Green Team.
- Originally developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995.
- In 1995, Time magazine called Java one of the Ten Best Products of 1995.
- JDK 1.0 released in(January 23, 1996).
Java Program that display India Map
Try It !!!!!!
public class Pattern
{
public static void main(String[] args) throws Exception
{
int a=10,b=0,c=10;
String s1="TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^NBELPeHBFHT}TnALVlBLOFAkHFOuFETpHCStHAUFAgcEAelclcn^r^r\\tZvYxXyT|S~Pn SPm SOn TNn ULo0ULo#ULo-WHq!WFs XDt!";
a=s1.charAt(b);
while (a != 0)
{
if (b < 170)
{
a = s1.charAt(b);
b++;
while (a > 64)
{
a--;
if (++c=='Z')
{
c/=9;
System.out.print((char)(c));
}
else
System.out.print((char)(33 ^ (b & 0x01)));
}
}
else
break;
}
}
}
public class Pattern
{
public static void main(String[] args) throws Exception
{
int a=10,b=0,c=10;
String s1="TFy!QJu ROo TNn(ROo)SLq SLq ULo+UHs UJq TNn*RPn/QPbEWS_JSWQAIJO^NBELPeHBFHT}TnALVlBLOFAkHFOuFETpHCStHAUFAgcEAelclcn^r^r\\tZvYxXyT|S~Pn SPm SOn TNn ULo0ULo#ULo-WHq!WFs XDt!";
a=s1.charAt(b);
while (a != 0)
{
if (b < 170)
{
a = s1.charAt(b);
b++;
while (a > 64)
{
a--;
if (++c=='Z')
{
c/=9;
System.out.print((char)(c));
}
else
System.out.print((char)(33 ^ (b & 0x01)));
}
}
else
break;
}
}
}
Subscribe to:
Posts
(
Atom
)