public class Fibonacci { public static long fib(int n) { if (n <= 1) return n; else return fib(n-1) + fib(n-2); } public static void main(String[] args) { int N = Integer.parseInt(args[0]); for (int i = 1; i <= N; i++) System.out.println(i + ": " + fib(i)); }...
Browse » Home » Archives for June 2009
Palindrome String
import java.util.*;public class CheckPalindrome{public static void main(String[] args) {String str="madam";Stack s= new Stack();int i,count=0;char array[]=str.toCharArray();for(i=0;i(less than symbol)array.length;i++) {char arr=array[i];s.push(arr);}for(i=0;i(less than symbol)array.length/2;i++) {char st=array[i];Object ob=s.pop( );if(st==ob) {count++;}}if(count==array.length/2) {System.out.println("String is Palindrome");}else{System.out.println("String...
Palindrome number
import java.io.*;public class Palindrome { public static void main(String [] args){ try{ BufferedReader object = new BufferedReader( new InputStreamReader(System.in)); System.out.println("Enter number"); int num= Integer.parseInt(object.readLine()); int n = num; int rev=0; System.out.println("Number: "); System.out.println(" "+ num); for (int i=0; i<=num;...
File: Create a program for which out put wil be the same program
import java.util.*;import java.io.*;class Syam{ public static void main(String args[])throws Exception { PrintWriter pw=new PrintWriter(System.out,true); Scanner sc=new Scanner(new File("Syam.java")); String s=null; try { while((s=sc.nextLine())!=null) { pw.println(s); } } catch(Exception e) { } ...
Difference Between Two Daysimport java.io.*;import java.util.*;import java.util.Date.*;import java.util.Calendar;import java.lang.Math.*;import java.util.StringTokenizer;public class DateDemo{ String s,s1; int i; int d,d1,m,m1,y,y1; public void add(String a,String b) { s=a; s1=b; StringTokenizer ss=new StringTokenizer(s,"/"); while(ss.hasMoreTokens()) { d=Integer.parseInt(ss.nextToken()); m=Integer.parseInt(ss.nextToken());...
JavaScript Tutorials
JavaScript can be used to validate forms, provide interactive calendars, post the current day's headlines, produce background effects on a Web page, and play games, among many other things. Netscape created JavaScript in 1995. It was originally called "LiveScript”. An Introduction JavaScript is not Java JavaScript can either be client-side or server-side JavaScript is an object-based scripting language JavaScript is...
Microsoft to strip Internet Explorer browser
San Francisco: Microsoft is to strip its Internet Explorer browser from the new version of its Windows 7 operating system that it sells in Europe, the company announced Thursday.Microsoft said the move was designed to meet criticism from European Union (EU) regulators who have launched an investigation into whether bundling the browser with the operating system is in breach of European anti-trust rules. "Given the pending Microsoft...
Kerala Enterance Results
Today Kerala Medical and Engineering results are to be published.For results through phones you can call through BSNL 155300 and from other phones 0471-2115054,2115098.Click to check your Resultswww.keralaresults.nic.inwww.cee.kerala.gov.inwww.results.kerala.nic.inwww.cee.kerala.gov.in/wap(Through GPRS Facility mobiles)Tags:Engineering Enterance results,Kerala Enterance Results,Kerala Engineering Enterance Results,Medical enterance...
Ajax ........
function selectIt(data) { var pars="Data="+data; // alert(pars); var url="district.php"; var myAjax=new Ajax.Request(url, { method:'post',parameters:pars,onComplete:showResponseAdd }); }function showResponseAdd(tst) { $('div2').innerHTML=tst.responseText; }function selectIt(data) { var pars="Data="+data; // alert(pars); var url="district.php"; ...
Ajax in a page
function selectIt(data) { var pars="Data="+data; // alert(pars); var url="district.php"; var myAjax=new Ajax.Request(url, { method:'post',parameters:pars,onComplete:showResponseAdd }); }function showResponseAdd(tst) { $('div2').innerHTML=tst.responseText; ...
Getting Started with Struts 2
Struts 2 is an interesting tool for creating web project.To do struts 2 project in eclipse.Here we can use eclipse europa version..File- >new - >other->web- >dynamic web project-> next- >give project name- >next- > next->finish.Now you can see a folder in the project explorer having the name( here assume demo) that you have given.the directory structure for our application is given below.create folder...
MSSQL Connection
try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con = DriverManager.getConnection("jdbc:odbc:dsn"); }catch(Exception ex){ ex.printStackTrace(); ...
Mysql Connection
public UserDB() { try { Class.forName("com.mysql.jdbc.Driver"); con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ss","root","root"); } catch (Exception e) { System.out.println("GetConnection"+e); } ...
oracle connection
Class.forName("oracle.jdbc.driver.OracleDriver"); con = DriverManager.getConnection("jdbc:oracle:thin:@deepak:1521:orcl","scott","tiger"); } catch (Exception e) { e.printStackTrace(); ...
set path for jsp...
copy from--D:\Program Files\Apache Software Foundation\Tomcat 6.0\libservlet-api,jsp-api,el-apiand paste insideC:\Program Files\Java\jdk1.6.0_02\jre\lib\extSetting path------------set path for java thenJAVA_Home-C:\Program Files\Java\jdk1.6.0...
java coding For getting no of Days in a month
import java.util.Scanner;public class DateDemo{ public static void main(String[] args) { //Create scanner object to obtain input from user Scanner input = new Scanner (System.in); int MonthNum; //To hold the month from user input int Year; //To hold the year int numDays; String Month; System.out.print("Please enter the Month #"); MonthNum = input.nextInt(); System.out.print("Please enter...
Subscribe to:
Posts (Atom)