linear equation java
I don't know matrices, so I would solve it a different way.
You know enough to calculate m and b for each line
m = (y2-y1)/(x2-x1)
b = y1 - m(x1)
Calculate m and b for one line and m' and b' for the other.
Now at the intersection, x,y are the same on the two lines, so y = mx + b and y = m'x + b'. Therefore
mx + b = m'x + b'
x = (m'x + b' - b)/m
Plug x into mx + b to get y for that x.
You still have to ensure that the x,y you have found are on your line SEGMENTS; unless the lines are parallel, they will intersect somewhere, but not necessarily between the endpoints of the line segments you've started with.