Electrofriends

Java program to display Domain name service (DNS)

by Ranjith | April 30th, 2010.

Program : Domain name service (DNS) By : Kapil Lohia   import java.net.*;   class dns { public static void main(String args[]) throws Exception { try { InetAddress[] address=InetAddress.getAllByName("java.sun.com"); for(int j=0;j<address.length;j++) System.out.println(address[j]); }   catch(Exception e) { System.out.println("Error in accessing Internet :"+e); } } }

Read More..

Java program that displays the number of characters, lines and words in a text file

by Ranjith | October 2nd, 2009.

while((c=isr.read())!=-1)
{
chars++;
if(c==’\n’)
lines++;
if(c==’\t’ || c==’ ‘ || c==’\n’)
++words;
if(chars!=0)
++chars;
}

Read More..

Java program to read and display files

by Ranjith | October 2nd, 2009.

Wtire a Java program that reads a file and displays the file on the screen, with a line number before each line.

Read More..

Java program to display the information’s of the file

by Ranjith | October 2nd, 2009.

Write a Java program that reads on file name from the user then displays information about whether the file exists,whether the file is readable,whether the file is writable,the type of the file and the length of the file in bytes

Read More..

Java program using String Tokenizer class

by Ranjith | October 2nd, 2009.

Write a Java program that reads a line of integers and displays each integer and sum of all integers using String Tokenizer class

Read More..

Java Program to multiply two matrices

by Ranjith | October 2nd, 2009.

System.out.println(“Enter the first matrix:”);
Scanner input=new Scanner(System.in);
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
a[i][j]=input.nextInt();

Read More..

Java program to sort a given list of names in ascending order

by Ranjith | October 2nd, 2009.

for(int j=i+1;j {
if(names[i].compareTo(names[j])<0)
{
temp=names[i];
names[i]=names[j];
names[j]=temp;
}
}

Read More..

Java program that checks whether the given string is palindrome or not

by Ranjith | October 2nd, 2009.

StringBuffer s1=new StringBuffer(args[0]);
StringBuffer s2=new StringBuffer(s1);
s1.reverse();
System.out.println(“Given String is:”+s2);
System.out.println(“Reverse String is”+s1);

Read More..

Java program to print the prime numbers

by Ranjith | October 2nd, 2009.

Write a Java program that prompts the user for an integer and then prints out all prime numbers up to that integer.

Read More..

Java program to print Fibonacci sequence

by Ranjith | October 2nd, 2009.

Write a Java program that uses both recursive and non-recursive functions to print nth value in the Fibonacci sequence.

Read More..

Share and enjoy

    • Digg
    • Facebook
    • Technorati
    • StumbleUpon
    • Twitter
    • Reddit
    • del.icio.us
    • Yahoo! Buzz
Copyright©2009 www.electrofriends.com All Rights Reserved. Powered by Dhyeya