4. Let $n$ students be such that among any 3 of them, 2 know each other, and among any 4 of them, 2 do not know each other. Find the maximum value of $n$.

 untranslated text remains the same as requested.
4. The maximum value of $n$ sought is 8.

When $n=8$, the example shown on the right satisfies the requirements, where $A_{1}, A_{2}, \cdots, A_{8}$ represent 8 students, and a line between $A_{i}$ and $A_{j}$ indicates that $A_{i}$ and $A_{j}$ know each other.
Now, let's assume $n$ students meet the requirements, and we will prove that $n \leqslant 8$. For this, we first prove that the following two cases are impossible:
(1) If someone $A$ knows at least 6 people, say $B_{1}, \cdots, B_{6}$. By Ramsey's theorem, among these 6 people, there exist 3 who do not know each other (which contradicts the given condition that among any 3 people, 2 know each other); or there exist 3 people who all know each other, in which case $A$ and these 3 people form a group of 4 who all know each other, which also contradicts the given condition.
(2) If someone $A$ knows at most $n-5$ people, then there are at least 4 people who do not know $A$, and thus these 4 people all know each other, which is a contradiction.
Secondly, when $n \geqslant 10$, either (1) or (2) must occur, so $n$ does not meet the requirements at this time.
When $n=9$, to make (1) and (2) both not occur, each person must know exactly 5 other people, and in this case, the number of friend pairs (pairs of people who know each other) generated by the 9 people is $\frac{9 \times 5}{2} \notin \mathbf{N}^{*}$, which is a contradiction!
From the above, we know that the $n$ that meets the requirements is $\leqslant 8$, in summary, the maximum value of $n$ sought is 8.