Halfvalue.com: Online Shopping for Electronics, Computers, Textbooks, Books, Music, DVDs, Video Games & moreworld's cheapest shopping dealslowest price in Textbooks, apparel and accesoriesBooks, Music, DVDs & more
welcomebookselectronicsmusicdvd and vhsapparelsoftwarecomputer & video gamestoysall stores directory
   shopping cart shopping cart View and/or modify your account information. my account log in
      Gift Ideas
               Search our Shops           Top Searches | Top Keywords
 


Halfvalue.com
>E-Books Resources >Free Java ebook: Introduction to Programming Using Java Version 4.1.

TOP Free Ebooks
  Free e-book: Flash
  Free e-book: Python
  Free e-book: Hacking/  Hackers
  Free ebook : C, C++, C# (C Sharp)
 Free e-books
arrowFree e-book: Java
 Free e-book: Javascript
 Free e-book: PHP & MySQL
 Free e-book: Visual Basic & Visual Basic.NET
 Free e-book: Web Design, Web Promotion & Web Development
 Free e-book: Office, Word Processor, Spreadsheet & Related
 Other Free Computer &  Programming e-books
 Other Free e-book
free magazines
arrowFree Computer Magazine
 Free Internet Magazine
 Free Information Technology Magazine
 Free Multimedia Magazine
 Free Network Magazine
 Free Telecommunication & Wireless Magazine
 
"INTRODUCTION TO PROGRAMMING USING JAVA" is a free, on-line textbook. It is suitable for use in an introductory programming course and for people who are trying to learn programming on their own. There is probably enough material for a full year College programming course. There are no prerequisites beyond a general familiarity with the ideas of computers and programs.

Free Java ebook: Introduction to Programming Using Java Version 4.1.pdf, by David J. Eck

RSS   Add to Yahoo!  Add to Google  Add to My MSN

Generic Programming

GENERIC PROGRAMMING refers to writing code that will work for many types of data. We encountered the term in Section 8.3, where we looked at dynamic arrays of integers. The source code presented there for working with dynamic arrays of integers works only for data of type int. But the source code for dynamic arrays of double, String, JButton, or any other type would be almost identical. It seems silly to write essentially the same code over and over. As we saw in Section 8.3, Java goes some distance towards solving this problem by providing the ArrayList class. An ArrayList is essentially a dynamic array of values of type Object. Since every class is a sub-class of Object, objects belonging to any class can be stored in an ArrayList. This is an example of generic programming: The source code for the ArrayList class was written once, and it works for objects of any type. (It does, not, however, work for data belonging to the primitive types, such as int and double.)

Download free ebook : Introduction_to_Programming_Using_Java_Version_4.1.pdf
"Introduction to Programming Using Java.pdf" is a free, on-line textbook

It is no easy task to design a library for generic programming. Java's solution has many nice features but is certainly not the only possible approach. It is almost certainly not the best, but in the context of the overall design of Java, it might be close to optimal. To get some perspective on generic programming in general, it might be useful to look very briefly at generic programming in two other languages.

Generic Programming in Smalltalk

Smalltalk was one of the very first object-oriented programming languages. It is still used today. Although it has not achieved anything like the popularity of Java or C++, it is the source of many ideas used in these languages. In Smalltalk, essentially all programming is generic, because of two basic properties of the language.

First of all, variables in Smalltalk are typeless. A data value has a type, such as integer or string, but variables do not have types. Any variable can hold data of any type. Parameters are also typeless, so a subroutine can be applied to parameter values of any type. Similarly, a data structure can hold data values of any type. For example, once you've defined a binary tree data structure in SmallTalk, you can use it for binary trees of integers or strings or dates or data of any other type. There is simply no need to write new code for each data type.

Secondly, all data values are objects, and all operations on objects are defined by methods in a class. This is true even for types that are "primitive" in Java, such as integers. When the "+" operator is used to add two integers, the operation is performed by calling a method in the integer class. When you define a new class, you can define a "+" operator, and you will then be able to add objects belonging to that class by saying "a + b" just as if you were adding numbers. Now, suppose that you write a subroutine that uses the "+" operator to add up the items in a list. The subroutine can be applied to a list of integers, but it can also be applied, automatically, to any other data type for which "+" is defined. Similarly, a subroutine that uses the "<" operator to sort a list can be applied to lists containing any type of data for which "<" is defined. There is no need to write a different sorting subroutine for each type of data.

Put these two features together and you have a language where data structures and algorithms will work for any type of data for which they make sense, that is, for which the appropriate operations are defined. This is real generic programming. This might sound pretty good, and you might be asking yourself why all programming languages don't work this way. This type of freedom makes it easier to write programs, but unfortunately it makes it harder to write programs that are correct and robust. (See Chapter 9.) Once you have a data structure that can contain data of any type, it becomes hard to ensure that it only holds the type of data that you want it to hold. If you have a subroutine that can sort any type of data, it's hard to ensure that it will only be applied to data for which the "<" operator is defined. More particularly, there is no way for a compiler to ensure these things. The problem will show up at run time when an attempt is made to apply some operation to a data type for which it is not defined, and the program will crash.


more Free Ebooks
  Free e-book: Linux
  Free e-book: Oracle
  Oreilly Free e-books
  Free e-book: ASP, ASP.NET
 more to explore
arrowLatest Articles
 Mesothelioma Articles
arrowSEO Resources
 Textbook Knowledge Base
view guides
arrowBuying Guides
 Electronics Guides
 Movies Guides
 Toys Buying Guides
 Shopping Tips
 

Halfvalue.com Home  | Find Answers  | Watch Videos  | Halfvalue.co.uk | Halfvalue Einkaufen | Compare Textbook Prices | Travel | Directory of All Stores

Where's My Stuff?
> Track your recent orders.
> View your orders in Your Account.
Shipping & Returns
> See our shipping rates & policies.
> Return an item (here's our Returns Policy).
Need Help?
> Forgot your password? Click here.
> Visit our Help department.
               Search our Shops         Browse All Categories
 

Your department store source to buy cheap used and new items online 
Featured Items & Stores | Popular Searches 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14

HOME | SITE MAP | BUY | BUY BOOKS | SELL | TRACK | TOP SEARCHES | ACCOUNTPRIVACY POLICY | USER AGREEMENT | CONTACT US| AVAILABLE ITEMS| | BEST-SELLING BOOKS | RECENT SEARCHES | FEATURED ARTICLES | COMPARE TEXTBOOK PRICES | MORE BUYING OPTIONS
FIND A STORE | AUTO | BATH & BEAUTY | GIFTS | HOME IMPROVEMENT | JEWELRY | SPORTING GOODS | TOYS & HOBBIES | TRAVEL
VeriSign, Inc.®VisaMastercardAmerican ExpressDiscovereCheckPayPal Halfvalue.com Uses java Technology By Sun