Programming
All tutorials in Programming
Sort By:    Name   Rating   Views  Comments    Date 
Browse Pages :    <<  <  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  >  >> 
Classes (II)
Submitted 28 April 2008

Here you have an example that overloads the addition operator (+). We are going to create a class to store bidimensional vectors and then we are going to add two of them: a(3,1) and b(1,2). The addition of two bidimensional vectors is an operation as simple as adding the two x coordinates to obtain the resulting x coordinate and adding the two y coordinates to obtain the resulting y. In this case...

Views: 303 Comments: 0
Templates
Submitted 28 April 2008

Function templates are special functions that can operate with generic types. This allows us to create a function template whose functionality can be adapted to more than one type or class without repeating the entire code for each type. In C++ this can be achieved using template parameters. A template parameter is a special kind of parameter that can be used to pass a type as argument: just like...

Views: 345 Comments: 0

NAMES ARE FUNDAMENTAL TO PROGRAMMING. In programs, names are used to refer to many different sorts of things. In order to use those things, a programmer must understand the rules for giving names to things and the rules for using the names to work with those things. That is, the programmer must understand the syntax and the semantics of names.

Views: 390 Comments: 0

There is a fundamental difference between the primitive types and the String type: Values of type String are objects. While we will not study objects in detail , it will be useful for you to know a little about them and about a closely related topic: classes. This is not just because strings are useful but because objects and classes are essential to understanding another important programming...

Views: 337 Comments: 0
Text Input and Output - Java
Submitted 29 April 2008

FOR SOME UNFATHOMABLE REASON, Java seems to lack any reasonable built-in subroutines for reading data typed in by the user. You've already seen that output can be displayed to the user using the subroutine System.out.print. This subroutine is part of a pre-defined object called System.out. The purpose of this object is precisely to display output to the user. There is a corresponding object called...

Views: 241 Comments: 0
Details of Expressions - Java
Submitted 29 April 2008

New tutorial descriptionTHIS SECTION TAKES A CLOSER LOOK at expressions. Recall that an expression is a piece of program code that represents or computes a value. An expression can be a literal, a variable, a function call, or several of these things combined with operators such as + and >. The value of an expression can be assigned to a variable, used as the output value in an output routine,...

Views: 251 Comments: 0
Blocks, Loops, and Branches - Java
Submitted 29 April 2008

THE ABILITY OF A COMPUTER TO PERFORM complex tasks is built on just a few ways of combining simple commands into control structures. In Java, there are just six such structures -- and, in fact, just three of them would be enough to write programs to perform any task. The six control structures are: the block, the while loop, the do..while loop, the for loop, the if statement, and the switch...

Views: 298 Comments: 0
Algorithm Development - Java
Submitted 29 April 2008

PROGRAMMING IS DIFFICULT (like many activities that are useful and worthwhile -- and like most of those activities, it can also be rewarding and a lot of fun). When you write a program, you have to tell the computer every small detail of what to do. And you have to get everything exactly right, since the computer will blindly follow your program exactly as written. How, then, do people write any...

Views: 309 Comments: 0
The while and do..while Statements
Submitted 29 April 2008

STATEMENTS IN JAVA CAN BE either simple statements or compound statements. Simple statements, such as assignments statements and subroutine call statements, are the basic building blocks of a program. Compound statements, such as while loops and if statements, are used to organize simple statements into complex structures, which are called control structures because they control the order in which...

Views: 398 Comments: 0
The for Statement - Java
Submitted 29 April 2008

WE TURN IN THIS SECTION to another type of loop, the for statement. Any for loop is equivalent to some while loop, so the language doesn't get any additional power by having for statements. But for a certain type of problem, a for loop can be easier to construct and easier to read than the corresponding while loop. It's quite possible that in real programs, for loops actually outnumber while...

Views: 430 Comments: 0
The if Statement-Java
Submitted 29 April 2008

Now, an if statement is, in particular, a statement. This means that either statement-1 or statement-2 in the above if statement can itself be an if statement. A problem arises, however, if statement-1 is an if statement that has no else part. This special case is effectively forbidden by the syntax of Java. Suppose, for example, that you type

Views: 359 Comments: 0
The switch Statement-Java
Submitted 29 April 2008

THE SECOND BRANCHING STATEMENT in Java is the switch statement, which is introduced in this section. The switch is used far less often than the if statement, but it is sometimes useful for expressing a certain type of multi-way branch. Since this section wraps up coverage of all of Java's control statements, I've included a complete list of Java's statement types at the end of the section.

Views: 456 Comments: 0
Introduction to Applets and Graphics
Submitted 29 April 2008

FOR THE PAST TWO CHAPTERS, you've been learning the sort of programming that is done inside a single subroutine. In the rest of the text, we'll be more concerned with the larger scale structure of programs, but the material that you've already learned will be an important foundation for everything to come.In this section, before moving on to programming-in-the-large, we'll take a look at how...

Views: 303 Comments: 0

EVERY SUBROUTINE IN JAVA MUST BE DEFINED inside some class. This makes Java rather unusual among programming languages, since most languages allow free-floating, independent subroutines. One purpose of a class is to group together related subroutines and variables. Perhaps the designers of Java felt that everything must be related to something. As a less philosophical motivation, Java's designers...

Views: 364 Comments: 0
Parameters - Java
Submitted 29 April 2008

IF A SUBROUTINE IS A BLACK BOX, then a parameter provides a mechanism for passing information from the outside world into the box. Parameters are part of the interface of a subroutine. They allow you to customize the behavior of a subroutine to adapt it to a particular situation.

Views: 388 Comments: 0
Browse Pages :    <<  <  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  >  >>