s john smith wrote:is it possible to traverse the array that contains string by incrementing a pointer?
s john smith wrote:is it possible to traverse the array that contains string by incrementing a pointer?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
s john smith wrote:... the array that contains string ...
Dennis Deems wrote:
s john smith wrote:... the array that contains string ...
Do you mean the char array encapsulated in a String instance?
fred rosenberger wrote:Java does not have pointers
The reference values (often just references) are pointers to these objects...
sanjay kumar gupta wrote:Most studies agree that pointers are one of the primary features that enable programmers to inject bugs into their code.
Given that structures are gone, and arrays and strings are objects, the need for pointers to these constructs goes away. Thus, Java has no pointer data types. Any task that would require arrays, structures, and pointers in C can be more easily and reliably performed by declaring objects and arrays of objects.
Instead of complex pointer manipulation on array pointers, you access arrays by their arithmetic indices. The Java run-time system checks all array indexing to ensure indices are within the bounds of the array.
You no longer have dangling pointers and trashing of memory because of incorrect pointers, because there are no pointers in Java.

Jeff Verdegan wrote:
sanjay kumar gupta wrote:Most studies agree that pointers are one of the primary features that enable programmers to inject bugs into their code.
Given that structures are gone, and arrays and strings are objects, the need for pointers to these constructs goes away. Thus, Java has no pointer data types. Any task that would require arrays, structures, and pointers in C can be more easily and reliably performed by declaring objects and arrays of objects.
Instead of complex pointer manipulation on array pointers, you access arrays by their arithmetic indices. The Java run-time system checks all array indexing to ensure indices are within the bounds of the array.
You no longer have dangling pointers and trashing of memory because of incorrect pointers, because there are no pointers in Java.
This sounds like a quote from somewhere. If it is, please give proper credit to the source. If it is in fact your own thoughts in your own words, please accept my apologies and carry on.![]()
s john smith wrote:i am new to java and i was trying to solve the exercise question. this is the question-"Write a function that takes a string as argument and displays it vertically char by char. Traverse the array by incrementing a pointer." after reading this got confused because there is no concept of pointers in java
s john smith wrote:this is the question-"Write a function that takes a string as argument and displays it vertically char by char. Traverse the array by incrementing a pointer."
s john smith wrote:so if it is char array,how can i use pointer? can you elaborate?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
| With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |