A feature of Java that usually confuses beginners is the "this" prefix.
In a nutshell, the this keyword is used to distinguish between parameters of a method and attributes (instance variables) of a class.
The following link will lead you to a web page that does a great job contrasting and explaining this with examples:
Mostly Computer Science-related topics and resources, especially Linux and education (IB, IGCSE).
Thursday, 3 March 2016
Sunday, 7 February 2016
Distribute your Java classes in a JAR file
The source of the information given in this post is
http://www.skylit.com/javamethods/faqs/createjar.html
In my opinion, the simplest and quickest way to do this is using the command line.

Steps
In my opinion, the simplest and quickest way to do this is using the command line.

Steps
- Start the Command Prompt. The easiest way is to Shift-Right Click on an empty spot in your Windows (File) Explorer. Make sure no files are selected, though. The idea is that your Windows Explorer should be in the location of your Java files.
- Navigate
to the folder that holds your class files:
Copy the path from Windows Explorer's address bar (more details about WE here), then type the following into the command prompt window:
cd /d -
minding the space at the end, then paste the path that you copied from Windows Explorer's address bar. Press Enter.
- If
you haven't set your path to include JDK’s binaries (compiler and
utilities, including the one that creates jar files), you need to do so by
adding it to your default path (your folder may differ depending on the
version of the JDK that you installed)
path %path%;C:\Program Files\Java\jdk1.8.0_83\bin - Compile
your class(es):
javac *.java -
Create a manifest file and your jar file (Replace IA with the relevant name to your project):
echo Main-Class: IA > manifest.txt
jar cvfm IA.jar manifest.txt *.class
---- or ----
jar cvfe IA.jar IA *.class - Test your jar:
java -jar IA.jar -
Create a batch file so your end user can double click on it to run your command line application (you may also use Notepad to do this):
copy con run.bat (creates the file)
java -jar IA.jar (Press CONTROL Z and Enter to finish and save the file) - Double click on run.bat to test it.
Thursday, 28 January 2016
IBDP Computer Science IA
Important information about the
IBDP Computer Science Internal Assessment
Screencasting & File Requirements
Mac:Windows:
Ensure that your screencast is about 5 minutes long, and in MP4, MOV, M4V format;
Maximum size 500 MB
Formatting of work for IBDP Computer Science IA
- Arial font size 12 (where the language / script supports it)
- Double-line spacing
- Numbered pages
- Portrait orientation (rather than landscape) – except where it is necessary to accommodate a specific item such as a graph or illustration
- DOC, DOCX, PDF or RTF
Tuesday, 22 December 2015
Java Scanner class confusion
If you have used Java's Scanner class, yopu may have come across an odd behaviour as you use the same Scanner object to input numbers and Strings.
I recently found the best explanation for this behaviour (it's not a bug), which you may find and here here at Daniweb. The best replies are from cgeier and BestJewSinceJC
Hope you find these useful.
I recently found the best explanation for this behaviour (it's not a bug), which you may find and here here at Daniweb. The best replies are from cgeier and BestJewSinceJC
The reason it gives you trouble is because when the user enters an integer then hits enter, two things have just been entered - the integer and a "newline" which is \n. The method you are calling, "nextInt", only reads in the integer, which leaves the newline in the input stream. But calling nextLine() does read in newlines, which is why you had to call nextLine() before your code would work. You could have also called next(), which would also have read in the newline. (BestJewSinceJC)
Just change the delimiter.
Scanner in = new Scanner(System.in); in.useDelimiter("\n");(cgeier)
Hope you find these useful.
Monday, 30 November 2015
What is usability?
I have been looking for useful definitions of usability within the context of Computer Science.
I'll update this post as I find more and better resources.
I'll update this post as I find more and better resources.
Wednesday, 11 November 2015
Binary Search Trees
Best Links to Revise: Binary Search Trees (BSTs)
- http://visualgo.net/bst.html - animated binary search trees (BSTs)
- http://www.algolist.net/Data_structures/Binary_search_tree
- http://www.geeksforgeeks.org/618/ - BST traversals
- A great wikibook for A Level Computing including the best way to learn BST traversals
- http://www.cs.swarthmore.edu/~newhall/unixhelp/Java_bst.pdf - slideshow on BSTs
- https://www.cs.rochester.edu/~gildea/csc282/slides/C12-bst.pdf - more slides on BSTs; recommended to read up to and including the topic on deleting a node from a BST
- Trees and tree algorithms from the interactivepython.org
Subscribe to:
Posts (Atom)
Optimise Windows 10/11
How to optimise your Windows setup Just in case you need it. If you want a safe and conservative approach, just disable the background apps ...
-
Lenovo Ideapad S10-3 If you have a Lenovo Ideapad S10-3 (depicted above), and you want to test or install shiny new Ubuntu 10.10 on it,...
-
This brief post shows how to create a bi-dimentional array and describe it using IB pseudocode. It isn't stated in the IB Pseudocode in ...
-
In order to program in Java, you may want to follow the instructions and videos that I have prepared. They are simle and straightforward, an...