Some basic Java Questions

JC0724

Weaksauce
Joined
Oct 11, 2008
Messages
105
1st is an OOP inheritance question.

If I have

class A {
//some public methods
}

class B extends A {
//some public methods
}

class C extends B{
}

Can Class C access public methods of Class A, even though it extends from B not A??

2nd Question if I am using JAVA to open a delimited test file, and I am parsing the contexts by some text delimiter, my question is what does delimiter mean??
 
Can Class C access public methods of Class A, even though it extends from B not A??

Yes. If we replace A with animal, B with dog, and C with pit bull, pit bulls can still do animal things, because they're still animals.
 
As to your 2nd question... "delimiter" is the character (or string) that separates the actual data you want to use.

E.g., a CSV file is "Comma Separated Values" where the comma (,) is the delimiter.
 
A delimiter is one or more characters that denotes the boundaries of individual elements in a sequence of elements. For example:

Code:
amd,intel,nvidia,apple,google,facebook

The delimiter, in this case is "," (the comma).
 
Delimiters come in a wide variety

pipes
The|dog|ran

commas
The,dog,ran

"
"The""dog""ran"
(trick one if they are not always pairs or singular but a mix)

Even spaces
The dog ran

SSV (semi colon separate values)
The;dog;ran
 
Thanks, does Java have any predefined methods that can be used to parse delimted text files?
 
Thanks, does Java have any predefined methods that can be used to parse delimted text files?

Looking through the doc helps in this situation. You're gonna have to start doing that anyway if you get into Java. Or at least googling something like "java split string by delimiter". As expected, the first result answers your question.

In this case, you're looking for the String.split() function - https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split(java.lang.String)

Of course, before that you need to read your file into a string. Do a similar google search to figure that out.
 
Back
Top