Hi guys,

I'm still quite new to programming and have an exam soon where we have to hand-write programs(no IDE). Never done this before, just you guys all give fantastic guidance, i wanted to see what you all thought. Any general advice would be appreciated!

Theres some small things im unsure of like if you write a small program is it ok to put it all in a public static void main? or should i include method calls in the psvm? or should i not include psvm and use public void main() to call methods?

Also when asked to declare an array is:

int[] numbersArray = {41, 87, 54, 34, 24, 100, 33, 51}

okay ? (i mean i know it works, but is that all that would be expected of you?) I read somewhere that an array should(or has to) always declare how many elements there will be inside. Or is that done here by simply initialising the 8 elements? I've seen an array declared as ...array = new array[12] etc, i really dont understand the difference or why you would do the latter.

Thank you (I know its a bit of a mess, sorry lol)

I.M.H.O.
1. Very tiny programs can go in the main(...) method, but it's far better practice to split programs up into classes and methods and just use main to get them started.
2. Declaring an array like that is absolutely fine. Just check that the following code gets the array size dynamically and does not hard-code the length (in case the declaration changes)
3. You have to declare an array with explicit size eg [12] if you are going to put the data into itr later.

Thats great man thanks.

I had to handwrite my programs during tests in Pascal, very annoying. Though I'd imagine it'd be more annoying for the teacher to grade 30 papers like that. Here's a tip, plan out ahead of time what you're going to write. On paper it's a lot harder to insert a new line in the middle of the page ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.