






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







1 Inf1-OOP Tutorial: Week 1
public class Repeat {
public static void main(String[] args) { int num = 0; for ( int count = 0; count < 20; count++) { num = count; System.out.print(num); } System.out.println(num); System.out.println(count); } }
public class TraceLoop {
public static void main( String [] args ) { int j = 0; for ( int i = 1; i < 5; i++) { j = j + i; System.out.println("i is: " + i); System.out.println("j is: " + j); System.out.println(); } } }
3 Inf1-OOP Tutorial 3: Week 5
public class Wonky {
int n1; double n2; String s;
public int foo(String[] aString) { int n3; String s2; aString[42] = s + n3; if (aString.length <= 3) { return aString[3]; } else { n1 = Integer.parseInt(s); return n2; } return n1 + n3;
public static void main(String[] args) { int [] anArray = { 3, 4, 5 }; anArray[0] = ( double ) 5; System.out.println("The value of foo is " + foo(anArray, anArray[n3]); } }
import java.util.Scanner ;
public class InsertRow {
public static void main(String[] args) { String name; int amount;
Scanner input = new Scanner(System.in); System.out.print("Please enter beneficiary’s name and amount to transfer"); name = input.next(); amount = input.nextInt(); String sql = "INSERT\nINTO Transfers (beneficiary, amount)\nVALUES (" + name + " System.out.println(sql); } }
public class SumOddsEvens { public static void main( String [] args ) { int sumEven = 0; int sumOdd = 0; for ( int i = 0; i < args.length; i++ ) { int temp = Integer.parseInt(args[i]); if ( temp % 2 == 0 ) { sumEven += temp; }
else { sumOdd += temp;}} System.out.println("The sum of the even numbers is: " + sumEven); System.out.println("The sum of the odd numbers is: " + sumOdd); } }
for ( int i = pos; i < valuesSize; i++) { values[i] = values[i + 1]; } valuesSize--;
if (valuesSize < values.length) { for ( int i = valuesSize; i > pos; i--) { values[i] = values[i - 1]; } values[pos] = elem; valuesSize++; }
getTitle() setTitle(String)
showRelated() getFileSize() addAnnotation(String)
getTitle() setTitle(String) showRelated() getFileSize() compress(Float) // arg provides the compression ratio convertToPDF()
getTitle() setTitle(String) showRelated() getFileSize() compress(Float) convertToPDF() convertToHTML()
getTitle() setTitle(String) getFileSize() makeThumbnail() getResolution()
getTitle() setTitle(String) getFileSize() makeThumbnail() getDTD() addEventHandler(Action)
getTitle() setTitle(String) getFileSize() getBitRate() getPlayTime()
getTitle() setTitle(String) getFileSize() getBitRate()
5 Indices and tables