Tuesday 27 January 2015

Program for Shifting characters in a String eg. String "abcde" should be printed as "eabcd"



import java.util.Scanner;

public class SB
{
public static void main(String []args) {

Scanner in = new Scanner(System.in);

         System.out.println("Enter a string to shift characters");
      String  test = in.nextLine();


 For further visit    Javainhouse
Read More »

Saturday 24 January 2015

Find length of String without using any length or size method

import java.util.Scanner;


public class SB

{

public static void main(String[] args) {

{
String test;
      Scanner in = new Scanner(System.in);

     For further program please visit my new blog http://javainhouse.blogspot.com










Read More »

Print "welcome bangalore" as welcome erolagnab

import java.util.Scanner;


public class SB

{

public static void main(String[] args) {

{
String test="welcome bangalore";

String reverse="";


 int i=0;

 String a[]=test.split(" ");


 for (int j = a[1].length()-1; j >= 0; j--)
 {

reverse = reverse + a[1].charAt(j);
 }


 a[1]=reverse;
 test=a[0] +" "+ a[1];
 System.out.println(test);



}
}
}











Read More »

Thursday 22 January 2015

Program in java to check whether a String is palindrome or not

import java.util.*;
public class Palindrome
{
   public static void main(String args[])
   {
      String original, reverse = "";
      Scanner in = new Scanner(System.in);
 
Program in java to check whether a String is palindrome or not       System.out.println("Enter a string to check palindrome");
      original = in.nextLine();
 
      int length = original.length();
 
      
     
      for ( int i = length - 1 ; i >= 0 ; i-- )
         reverse = reverse + original.charAt(i);
 
      if(reverse.equals(original))
      System.out.println("Yes String is palindrome");
      else
       System.out.println("NO String is not palindrome"); 
   }
}
Read More »

Program to split a String without using split() method



Program to split a String without using split() method import java.util.*;
public class SplitString
{
public static void main(String[] args) {
   String[] s = {"Netherlands_Iceland_Norway_Denmark"};
   String[] finalString = mymethod(s);      
   for (int i = 0; i < s.length; i++) {
       System.out.println("" + finalString[i]);
   }
}

static public String[] mymethod(String[] mystring) {
   String ss[] = new String[mystring.length];
   for (int j = 0; j < mystring.length; j++) {
       ss[j] = mystring[j].replace('_', ' ');
   }
   return ss;
}
}

Read More »

Monday 19 January 2015

Introduction to JAXB and its Architecture

JAXB means JAVA API for XML Binding.

Introduction to JAXB and its Architecture In simple words, it means an API used to bind XML with JAVA objects.

JAXB provides an efficient and easy way to bind XML data to JAVA which is very helpful for java developer ,Mostly used in case of web services as data travel between web services and client in form of xml which is further needed to be converted into java object as a need for java application.This need can be fulfilled by JAXB.

Mainly two things can be understood as working of JAXB.
 1.       Conversion of java objects to XML which is known as Marshalling.
 2.       Conversion  of XML data to java object ,known as unmarshalling.



JAXB Architecture:



JAXB Architecture


JAXB Architecture consists of following components:

Schema Compiler
Schema Generator
Binding Runtime Framework

Schema Compiler is used to bind source schema with schema derived program elements.

Schema Generator maps set of Program elements to derived schema .This mapping is described by annotations.

Binding Runtime Environment : Provides unmarshalling (reading) and marshalling (writing) operations for accessing, manipulating, and validating XML content using either schema-derived or existing program elements.
Read More »