Java Forum

 Forum:   Subject:  View:  

 

 Blue Pelican Site
 Login/Edit Account


 Forgot your password?

 

     (Page 2 of 5)
<Prv  1  2 3  4  5  Nxt>  

Topic: Binary Search
ID: sa Date/Time: 04/13/2006 4:03:05 PM
Message:
Array num contains 100 integers in ascending order. Assume that you would like to see if num contains the integer 123. If a binary search is used to search for 123, what is the maximum number of elements taht must be examined?

Given an array of size 300, what is the maximum number of comparisons that you will need to make if you use a binary search algorithm to search for an element in the array?
Reply Title: An excuse to use logarithms  
ID: Author, Blue Pelican Java Date/Time: 04/16/2006 3:21:05 PM
Message:
Take the logarithm(base 2) of the number of elements and then truncate to an integer. Then add 1.

In java, find the log base 2 of n like so:

      Math.log(n)/Math.log(2)

Topic: Encapsulation?
ID: sa Date/Time: 04/13/2006 7:47:18 PM
Message:

public class Date implements Comparable
{
private int month;
private int day;
private int year;
...
}


Is the following code legal?
public int compareTo(Object other)
{

if(month==other.month)
   if(day==other.day)
        if(year==other.year)
              return true;
return false;

}
Reply Title: Not legal  
ID: Author, Blue Pelican Java Date/Time: 04/18/2006 4:34:55 AM
Message:
It's not legal for two reasons. First, the compareTo method is supposed to return an int. You have it returning a boolean. Second, the object called other passed as a parameter to compareTo needs to be cast as a Date object before doing the comparison in the if statement.

In all of this I assume that this compareTo method is part of the Date class in spite of the fact that it is set off by itself in your example.

Topic: Java File Handling
ID: kungfu alfalfa Date/Time: 05/04/2006 1:17:22 PM
Message:
Is it possible to save and load java files onto a disk? if so, how?
Reply Title: Yes, it is possible  
ID: Author, Blue Pelican Java Date/Time: 05/06/2006 6:53:35 AM
Message:
Lesson #26 of Blue Pelican Java details exactly how to do this. That lesson shows how to save on the hard drive. To save to a floppy, just substitute a:\\ where it says c:\\

Topic: http://www.freejavaguide.com
ID: Bob Date/Time: 07/03/2006 7:57:25 AM
Message:
Hi guys,

I made a site namely http://www.freejavaguide.com and hence would like to share some of the useful parts of the site that can be used be each of you.

INTERVIEW QUESTIONS
-----------------------------
Java
C
C++
SQL
Oracle
XML
HTML

JAVA PROGRAMMING
--------------------------
JAVA Tutorial
Java SCJP Notes 1
Java Test
SCJP Notes 2
Java JDBC Program Tutorial

ORACLE
------------
SQL Tutorial
PLSQL Tutorial

OTHERS
-------------
Information for Job Seekers
HTML Tutorial
Puzzles
Web mastery


NEW ATTRACTIONS
------------------------
FORUM
EBOOKS
WWE CDS
IT Walkins
SOURCE CODE  ( THE HOTTEST PART OF ALL)


and some IBM Programmers Tutorials.


Everything in the website can't be covered here and hence I would like you all to check out this site namely
http://www.freejavaguide.com

Topic: New Java Book
ID: Computer Dude Date/Time: 09/01/2006 12:38:44 PM
Message:
Are you thinking about or working on a new java book, because I can't wait to get it. If you are working on one. Can you tell me when it come out? I JUST CAN'T WAIT.
When you get done please e-mail me ASAP.

Topic: Run error
ID: GiGi Date/Time: 11/27/2006 12:39:25 PM
Message:
I am a first time Java teacher and I have no one to go to for help in my small district.  I have spent 12 weeks ironing out network computer problemsm, etc.  Short programs have been working fine now that we are looking at applets I am having problems again.  we are using JCreator and jdk.  Any help will be greatly appreciated.  Thanks,

import java.awt.*;
import java.applet.*;

public class GraShapes extends Applet {
    
    public void init() {
    }

    public void paint(Graphics g) {
        g.drawString("Welcome to Java!!", 50, 60 );
    }
}


Run error:  Exception in thread "main" java.lang. NoSuch Method Error:Main
Reply Title: Needs a run method  
ID: Author, Blue Pelican Java Date/Time: 11/28/2006 2:32:25 PM
Message:
Add a run method like this:

public void run( )
{
     repaint( );
}

Topic: help!!
ID: buff boy Date/Time: 11/30/2006 9:11:30 PM
Message:
help me with the gas mileage probelm ch. 16
Reply Title: Be specific  
ID: Author, Blue Pelican Java Date/Time: 12/01/2006 2:03:26 PM
Message:
Ask a specific question and not something as general as this.
  << New message thread

(Page 2 of 5)             <<PrevPage   1   2   3   4   5   NextPage>>  

This Forum automated by software from bluepelicanjava.com