Tag: code

Example Java Programs

HelloWorld.java public class HelloWorld {     // method main(): ALWAYS the APPLICATION entry point     public static void main (String[] args) {     System.out.println (“Hello World!”);     } } // Print Today’s Date import java.util.*; public class HelloDate {     public static void main (String[] args) {     System.out.println (“Hello, it’s: “);     System.out.println(new Date()); …

Continue reading

FruitCreation.java: Creates a simple table named fruits in either an Oracle or a Sybase database.

FruitCreation.java Creates a simple table named fruits in either an Oracle or a Sybase database. package cwp; import java.sql.*; /** Creates a simple table named “fruits” in either  *  an Oracle or a Sybase database.  *    */ public class FruitCreation {   public static void main(String[] args) {     if (args.length < 5) { …

Continue reading

Example illustrating inheritance and abstract classes

illustrating inheritance এবং abstract classes এর উদাহরণ Shape.java সব, বদ্ধ খোলা, বাঁকা, এবং সোজা পার্শ্বে ধারবিশিষ্ট আকার এর জন্য প্যারেন্ট ক্লাস (সারাংশ)। Curve.java একটি (সারাংশ) বাঁকা আকার (খোলা বা বন্ধ)। StraightEdgedShape.java সরাসরি ধার সম্বলিত একটি আকৃতি (খোলা বা বন্ধ)। Measurable.java পরিমাপযোগ্য এলাকায় ইন্টারফেস ডিফাইনিং ক্লাস। Circle.java একটি বৃত্ত যা আকার প্রসারিত করে এবং পরিমাপ প্রয়োগ …

Continue reading

Some simple utilities for building Oracle and Sybase JDBC connections

এই সাধারণ উদ্দেশ্যে তৈরিকৃত কোড নয় – এটা আমাদের লোকাল সেটআপ এর ক্ষেত্রে প্রযোজ্য।     package cwp; /** Some simple utilities for building Oracle and Sybase  *  JDBC connections. This is not general-purpose  *  code — it is specific to my local setup.  */ public class DriverUtilities {   public static final int ORACLE = …

Continue reading

FruitTest.java: A class that connects to either an Oracle or a Sybase database and prints out the values of predetermined columns in the “fruits” table.

# FruitTest.java  A class that connects to either an Oracle or a Sybase database and prints out the values of predetermined columns in the “fruits” table. package cwp; import java.sql.*; /** A JDBC example that connects to either an Oracle or  *  a Sybase database and prints out the values of  *  predetermined columns in …

Continue reading

J2SE : LinkedList and Iterators in Java

/*  * LinkedList.java  *  * Created on January 10, 2008, 8:51 PM  *  * To change this template, choose Tools | Template Manager  * and open the template in the editor.  */ package linkedlist; import java.util.List; import java.util.LinkedList; import java.util.Iterator; import java.util.ListIterator; import java.util.Collections; import java.util.Random; /**  *  * @author Sayed  */ public class LinkedListTest …

Continue reading

Use sorting criterion in sort function

/* The following code example is taken from the book  * “The C++ Standard Library – A Tutorial and Reference”  * by Nicolai M. Josuttis, Addison-Wesley, 1999  *  * (C) Copyright Nicolai M. Josuttis 1999.  * Permission to copy, use, modify, sell and distribute this software  * is granted provided this copyright notice appears in …

Continue reading

C++ code : Read file content

#include <iostream> #include <fstream> using namespace std; int main() {   ifstream in(“test”, ios::in | ios::binary);   if(!in) {     cout << “Cannot open input file.\n”;     return 1;   }   double num;   char str[80];   in.read((char *) &num, sizeof(double));   in.read(str, 14);   str[14] = ‘\0’; // null terminate str   cout …

Continue reading

Sort objects stored in deque

/* The following code example is taken from the book  * “The C++ Standard Library – A Tutorial and Reference”  * by Nicolai M. Josuttis, Addison-Wesley, 1999  *  * (C) Copyright Nicolai M. Josuttis 1999.  * Permission to copy, use, modify, sell and distribute this software  * is granted provided this copyright notice appears in …

Continue reading

Expressions.jsp Page that demonstrates JSP expressions. Uses the JSP-Styles style sheet.

Expressions.jsp  Page that demonstrates JSP expressions. Uses the JSP-Styles  style sheet. <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <!– Example of JSP Expressions.     Taken from Core Web Programming Java 2 Edition from Prentice Hall and Sun Microsystems Press, . May be freely used or adapted. –> <HTML> <HEAD> <TITLE>JSP Expressions</TITLE> <META NAME=”keywords”       …

Continue reading