Skip to main content

Posts

Showing posts from March, 2016

Play febnocci and factorial on BigNumbers ...

BigNumberOperations.java --------------------------------------------- package com.blogspot.developerssbrain; import java.math.BigDecimal; public class BigNumberOperations {     static BigDecimal factorial(int n){         BigDecimal fact=new BigDecimal("1");         while(n>0){             fact=fact.multiply(new BigDecimal(n));             n--;         }         return fact;     }         static BigDecimal febnocci(int n){         BigDecimal i=new BigDecimal("1");         BigDecimal j=new BigDecimal("1");         while(n-2>0){             j=j.add(i);      ...

Nested Classes

OuterClass.java ------------------------------------------------------------ package org.developerssolutions; public class OuterClass {     public void method(){         System.out.println("OuterClass.Method1");     }         class InnerClass{         public void method(){             System.out.println("OuterClass.InnerClass.Method1");         }         class InnerInnerClass{             public void method(){                 System.out.println("OuterClass.InnerClass.InnerInnerClass.Method1");             }         }     }     } Test.java ---------------...

Web Client to print weather report for the input City and Country

Java program to print weather report Steps: 1.Download the WSDL file from the URL http://www.webservicex.net/globalweather.asmx?WSDL 2.Create a java project in Eclipse 3.Copy the WSDL file to java project 4.Expand the java project in Eclipse and right click on the WSDL file and generate webservice client 5.Rename the package name into your source folder to your desired name 6.Add the following Main Class to your package Main.java package org.susil.solutions; import java.io.IOException; import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.CharacterData; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.SAXException; public class Main {     public static String getCharacterDataFromElement(Element e) {     ...