Neither system will cancel all in-person classes. Laboratory courses could continue to be held, although potentially with fewer students.

CUNY officials said separately on Wednesday that in-person classes were being canceled from Thursday through next Wednesday so that students and faculty members could prepare for the move to online classes.

Some dormitories will probably remain open for students who cannot return home for hardship reasons.

“They are not evicting anyone,” Mr. Cuomo said at a news conference. “They are not closing the dorm and kicking you out.”

The purpose of the move was to “reduce density,” the governor said.

Some SUNY and CUNY graduation ceremonies will probably “not be happening in person” this spring, said Melissa DeRosa, a top aide to the governor.

The decision to shift most public university classes in New York online followed similar moves by most major private universities in the state this week. However, private universities like Columbia and New York University have not said the suspension of in-person classes would last through the rest of the spring semester, which typically ends in May.

SUNY’s student government body, the Student Assembly, released a statement on Wednesday saying students “appreciate” Mr. Cuomo’s decision.