Skip to main content

Posts

Java Sample: While loop with String Buffer

import java.io.*; public class whilechk {     public static void main(String args[])     {         StringBuffer string=new StringBuffer();         char c;         System.out.println("\nEnter a String");         try         {             while((c=(char)System.in.read())!='\n')             {                 string.append(c);             }         }         catch (Exception e)         {                System.out.println(e.getMessage());         }         System.out.println("\nYou Have Entered ... " + string);     } }

Java Sample 1: User Define Function with Exception Handling

import java.io.*; public class logicbase { public static void main(String args[]) { System.out.println("\nHello This Is The First Logical Programme"); DataInputStream in=new DataInputStream(System.in); try { int x,y; System.out.println("\nEnter A Number :: "); x=Integer.parseInt(in.readLine()); System.out.println("\nEnter A Number :: "); y=Integer.parseInt(in.readLine()); System.out.println("Bigger No is :: "+max(x,y)); } catch(Exception e) { System.out.println(e.getMessage()); } } public static int max(int p,int q) { if(p>q) { return p; } else { return q; } } }

Creating Custom Java Simple Functions

Creating Custom Java Simple Functions Simple custom Java functions can be called in expressions in the context of most   StreamBase   components, other than the Aggregate operator. Follow these steps to create a custom Java simple function: ·          Use the   New StreamBase Java Function   wizard to create the base code, as described in   Using the StreamBase Java Function Wizard . ·          Implement a   public static   in a public Java class. ·          Observe the guidelines in   Method Parameter and Return Types . For example,   Hypotenuse.java   in the sample application declares the following class and method: public class Hypotenuse {     public static double calculate(double a, double b) {         return Math.sqrt(a*a + b*b);     } } At co...